Cron作业无法执行


0

我有以下cron工作:

* * * * /usr/local/bin/email_redirect
* * * * /usr/local/bin/email_redirect

python脚本永远不会运行,也不会写入syslog:

Nov 27 19:09:41 raspberrypi crontab[30824]: (pi) BEGIN EDIT (pi)
Nov 27 19:11:07 raspberrypi crontab[30824]: (pi) END EDIT (pi)
Nov 27 19:11:12 raspberrypi crontab[30837]: (pi) BEGIN EDIT (pi)
Nov 27 19:13:43 raspberrypi crontab[30837]: (pi) END EDIT (pi)

我正在使用crontab -e编辑配置。我究竟做错了什么?


cron守护程序正在运行吗?service cron status
fredden

Answers:


2

您在cron行识别中缺少一个*

语法应该是,有趣的用户cron

*     *     *   *    *        command to be executed
-     -     -   -    -
|     |     |   |    |
|     |     |   |    +----- day of week (0 - 6) (Sunday=0)
|     |     |   +------- month (1 - 12)
|     |     +--------- day of        month (1 - 31)
|     +----------- hour (0 - 23)
+------------- min (0 - 59)

0

Cron需要知道如何执行python脚本,因此您需要将路径添加到python可执行文件并调用该脚本。

像这样:

* * * * /path/to/python /usr/local/bin/email_redirect

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.