How would I get a cron job to run every 30 minutes?

前端 未结 6 1221
鱼传尺愫
鱼传尺愫 2020-12-04 07:36

I\'m looking to add a crontab entry to execute a script every 30 minutes, on the hour and 30 minutes past the hour or something close. I have the following, but

6条回答
  •  抹茶落季
    2020-12-04 07:46

    You can use both of ',' OR divide '/' symbols.
    But, '/' is better.
    Suppose the case of 'every 5 minutes'. If you use ',', you have to write the cron job as following:

    0,5,10,15,20,25,30,35,....    *      *     *   * your_command
    

    It means run your_command in every hour in all of defined minutes: 0,5,10,...

    However, if you use '/', you can write the following simple and short job:

    */5  *  *  *  *  your_command
    

    It means run your_command in the minutes that are dividable by 5 or in the simpler words, '0,5,10,...'

    So, dividable symbol '/' is the best choice always;

提交回复
热议问题