Home  >  Q&A  >  body text

linux - crontab 每3个小时运行一次

crontab 每3个小时运行一次

这种情况,我保存时在8点,那么9点就会运行吗?
他这个每3个小时,是 什么时间点 的3个小时???

PHPzPHPz2744 days ago1176

reply all(2)I'll reply

  • PHP中文网

    PHP中文网2017-04-17 16:05:26

    m h dom mon dow command

    This is what is displayed when you open crontab, please explain

    m:分钟,0-59
    h:小时,0-23
    dom:日期,1-31
    mon:月份,1-12
    dow:星期,0-6,0为星期天
    command:命令

    The first one represents the minute, so you can just write the first one to indicate the minute to execute it

    All you have to do is limit the second parameter, hours

    1 */3 * * * php /path/to/your/cron.php        
    每隔3小时的第一分钟执行一次任务

    How do you understand the word "every" here? */1*无区别,所以可以省略。这里可以想想,*/3It’s easier to understand if it means a time divisible by 3.

    I blogged about it before, you can take a look: Using Crontab to execute PHP files regularly under Ubuntu

    reply
    0
  • 迷茫

    迷茫2017-04-17 16:05:26

    $ crontab -e
    1 */3 * * * commands

    This is executed every 3 hours. You can test it by yourself on how to execute it. For example, echotime to a file

    reply
    0
  • Cancelreply