Crontab Formatting - every 15 minutes

后端 未结 3 1771
情歌与酒
情歌与酒 2020-12-03 06:48

I\'m trying to get a simple crontab job to run every 15 minutes and am having trouble deciding how to format the timing.

What I\'ve been putting down is the followin

相关标签:
3条回答
  • 2020-12-03 07:12

    Crontab doesn't remember what time you "started" (presumably the time you executed the crontab -e or crontab filename command).

    If you want to run the job every 15 minutes starting from an arbitrary time, you'll have to specify that time. This:

    7-59/15 * * * * command
    

    will run at 7, 22, 37, and 52 minutes after each hour. That's assuming you're running Vixie cron, which is the most common implementation. For better portability, you can use:

    7,22,37,52 * * * * command
    

    And remember that you can't have spaces within any of the first 5 fields; 0, 15,30,45, as you had in your question, is invalid.

    0 讨论(0)
  • 2020-12-03 07:17

    0,15,30,45 for 15 minutes is incorrect.

    The better and simply way is */15 * * * * for 15 minutes.

    5 minutes
    */5 * * * *
    
    15 minutes
    */15 * * * *
    
    30 minutes
    */30 * * * *
    
    60 minutes
    0 * * * *
    
    1 day
    0 0 * * *
    
    0 讨论(0)
  • 2020-12-03 07:18

    You would format the crontab like this to get it to run every 15 minutes.

    */15 * * * * [path/to/script]

    0 讨论(0)
提交回复
热议问题