다음 명령은 프롬프트에서 작동하지만 crontab에서는 작동하지 않습니다.
grep abc /var/log/messages | grep "`date '+%B %d'`" | mail -s"abc log of `hostname`" shantanu.oak+`hostname`@gmail.com
매일 cron에 추가해야합니다.
답변
당신은 %
표지판 을 탈출해야 합니다. 그들은 crontabs에서 특별한 의미를 가지고 있습니다.
man (5) crontab:
Percent-signs (%) in the command, unless escaped with backslash (\),
will be changed into newline characters, and all data after the
first % will be sent to the command as standard input.
답변
이것은 귀하의 질문에 직접 대답하지는 않지만 / usr / local / bin (또는 ~ / bin 또는 적절한 것)에 스크립트 파일을 만들고 cron에서 호출하는 것이 좋습니다. 테스트하고 편집하기가 더 쉽습니다.