如何设置跨越夜晚并每15分钟运行一次的cron作业

时间:2023-01-31 01:08:44

How to set up a cron job to run from 2300 hrs to 0515 hrs(next morning) from Sunday to Thursday(job ends on Friday morning)

如何设置从周日到周四2300小时(第二天早上)运行的cron作业(周五早上的工作结束)

This is a specific requirement since my hostgator server is set to Chicago time and I need a job to run from Monday to Friday Indian Standard Time.

这是一个特定的要求,因为我的hostgator服务器设置为芝加哥时间,我需要一个工作从星期一到星期五印度标准时间运行。

1 个解决方案

#1


You will need three cron expressions to achieve exactly what you ask for:

您将需要三个cron表达式来实现您的要求:

  1. 23:00 - 23:59 (Sun-Thu, every 15 min)

    23:00 - 23:59(周四至周四,每15分钟一班)

    */15 23 * * 0-4 command
    
  2. 00:00 - 4:59 (Mon-Fri, every 15 min)

    00:00 - 4:59(周一至周五,每15分钟一班)

    */15 0-4 * * 1-5 command
    
  3. 5:00, 5:15 (Mon-Fri)

    5:00,5:15(周一至周五)

    0,15 5 * * 1-5 command
    

Good luck!

#1


You will need three cron expressions to achieve exactly what you ask for:

您将需要三个cron表达式来实现您的要求:

  1. 23:00 - 23:59 (Sun-Thu, every 15 min)

    23:00 - 23:59(周四至周四,每15分钟一班)

    */15 23 * * 0-4 command
    
  2. 00:00 - 4:59 (Mon-Fri, every 15 min)

    00:00 - 4:59(周一至周五,每15分钟一班)

    */15 0-4 * * 1-5 command
    
  3. 5:00, 5:15 (Mon-Fri)

    5:00,5:15(周一至周五)

    0,15 5 * * 1-5 command
    

Good luck!