【问题标题】:Cronjob is triggered automaticallyCronjob 自动触发
【发布时间】:2017-02-21 01:35:27
【问题描述】:

我创建了一个 cron 作业,需要在每天 00:01 触发。详情如下:

Cronjob 配置:

01 00 * * * root /usr/bin/python /opt/scripts/tune.py -t & >/dev/null &

文件的权限和位置:

root@localhost:/etc/cron.d# ll /etc/cron.d/database_tuning
-rw-r--r-- 1 root root 80 Oct 12 01:04 /etc/cron.d/database_tuning

但是,此 cronjob 不会在指定的时间间隔内自动触发。现在,一旦我编辑此文件,并将时间更改为上午 01:12,例如 (12 01 * * *)。然后自动触发成功。所以我确认脚本/环境没有问题,但我无法理解为什么 cronjob 没有在 00:01 AM 触发。最好的调试方法是什么?

【问题讨论】:

  • 01 0 * * * root /usr/bin/python /opt/scripts/tune.py -t & >/dev/null &-----> 我相信应该只有一个以小时为单位输入数字,编号从 0-23 开始。

标签: linux cron centos centos6


【解决方案1】:

正如阿里所说,小时字段必须是0-23之间的值,所以写00是行不通的。

时间和日期字段是:

      field          allowed values
      -----          --------------
      minute         0-59
      hour           0-23
      day of month   1-31
      month          1-12 (or names, see below)
      day of week    0-7 (0 or 7 is Sunday, or use names)

一个字段可能包含一个星号 (*),它始终代表 “先到后”。

看看crontab manual page

【讨论】:

    猜你喜欢
    • 2021-12-16
    • 2021-11-30
    • 2022-01-20
    • 1970-01-01
    • 2010-12-16
    • 2013-01-28
    • 1970-01-01
    • 1970-01-01
    • 2013-11-29
    相关资源
    最近更新 更多