setup cron tab to specific time of during weekdays

前端 未结 3 1958
无人共我
无人共我 2020-12-13 22:59

I am trying to setup a cron job on a Ubuntu server. We want the cron job to run the script at certain times of the day and on some specific days of the week. For example, we

相关标签:
3条回答
  • 2020-12-13 23:26

    You state 2pm in your requirement, hour range should end at 14 instead of 18 (which is 6pm).

    */2 9-14 * * 1-5 /path_to_script
    

    man crontab

    http://unixhelp.ed.ac.uk/CGI/man-cgi?crontab+5

    0 讨论(0)
  • 2020-12-13 23:34

    In fact the last hour you want the script to run is 13:00 to 13:59, so you want:

    */2 9-13 * * 1-5 /path_to_script
    

    meaning the first runtime will be 9:00, then 9:02, and so on until 13:58 which will be the last run as 14:00 is not included.

    0 讨论(0)
  • 2020-12-13 23:40

    Same as you did for hours:

    */2 09-18 * * 1-5 /path_to_script
    

    0 and 7 stand for Sunday
    6 stands for Saturday
    so, 1-5 means from Monday to Friday

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