某些 CRON 作业未执行,例如:
crontab -e
- /usr/bin/echo“你好”
cron 正在运行
/var/log/syslog:
May 7 16:31:16 zika crontab[115379]: (brad) REPLACE (brad)
May 7 16:31:16 zika crontab[115379]: (brad) END EDIT (brad)
May 7 16:32:01 zika cron[39572]: (brad) RELOAD (crontabs/brad)
但其他工作都执行正常
有什么问题?
答案1
您的任务已执行。要查看它,请按照以下方式更改您的 cron 任务:
* * * * * /usr/bin/echo "hello" | logger
| logger
会将您的 发送echo
至syslog
以便您查看。但是,在您的情况下,如果没有,logger
它实际上会显示在您无法看到的某个虚拟终端中。
$ journalctl -f
тра 08 00:47:01 ubuntu CRON[21927]: pam_unix(cron:session): session opened for user user1 by (uid=0)
тра 08 00:47:01 ubuntu CRON[21929]: (user1) CMD (/usr/bin/echo "hello" | logger)
тра 08 00:47:01 ubuntu user1[21931]: hello
从man logger
:
DESCRIPTION
logger makes entries in the system log.
When the optional message argument is present, it is written to the log. If it
is not present, and the -f option is not given either, then standard input is
logged.