为什么我的时间'很糟糕'我的cron任务出错


Why am I receiving a 'bad hour' error in my cron task?

为什么我的cron任务给我一个'bad hour'错误

下面是我的cron任务(mycron.txt):
*/15 12-00 * * * php mycommand.php: bad hour errors in crontab file, can't install.

我想要的是每15分钟运行我的PHP脚本,每天从中午12点到午夜。

我正在运行我的cron crontab mycron.txt

理想的Cron表达式应该是:

  1. 从午夜到中午12点每15分钟运行一次:

    */15 00-12 * * *
    

(或)

  1. 从中午12点至午夜每15分钟运行一次。

    */15 00,12-23 * * *
    

下面的crontab将从12:00开始每15分钟运行一次,直到00:00,但不包括 00:00

# Example of job definition:
# .-------------------- minute (0 - 59)
# |    .--------------- hour (0 - 23)
# |    |    .---------- day of month (1 - 31)
# |    |    |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |    |    |  |  .---- day of week (0 - 6) (Sunday=0 or 7)
# |    |    |  |  |
# *    *    *  *  *     command to be executed
*/15 12-23  *  *  *     command

下面的crontab将从12:00开始每15分钟运行一次,直到00:00,但包括 00:00。为此,您需要两条线!

# Example of job definition:
# .-------------------- minute (0 - 59)
# |    .--------------- hour (0 - 23)
# |    |    .---------- day of month (1 - 31)
# |    |    |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |    |    |  |  .---- day of week (0 - 6) (Sunday=0 or 7)
# |    |    |  |  |
# *    *    *  *  *     command to be executed
*/15 12-23  *  *  *     command
  0    00   *  *  *     command