4

I need to run a CRON at midnight which auto-assigns some periodic tasks for the people working in my company. The situation I am facing is that my company basically has offices all around US, which has more than 1 timezone. So basically I would want the job to be done timezone-specific. Also, my server is running by UTC.

If I set EDT as the base timezone (which is 4 hours behind UTC) and set the CRON to be triggered at midnight, the CRON time would be

0 0 4 * * ?

The possible way that I think can be is that instead of setting it just once, I set it to be triggered 7 times at the following times:

0 0 4 * * ? [EDT]
0 0 5 * * ? [CDT]
0 0 6 * * ? [MDT]
0 0 7 * * ? [PDT]
0 0 8 * * ? [AKDT]
0 0 9 * * ? [HADT]
0 0 10 * * ? [HST]

So once any of it triggers, it would check which of my offices come under this time zone and will do the job.

This may work, as I believe, but does anyone else have any other option instead of this? Also, I would need to fix for the Daylight saving, which I am not really sure about how I would want to do.

4

1 回答 1

2

我认为最简单的方法可能是有一个每小时运行一次的工作,然后遍历所有办公室,并找到现在在晚些时候到工作最后一次运行的那个。(当然,您需要维护它以及办公室的时区。)这将为您解决 DST 问题,并应对调度程序停机一段时间的情况 - 下一次出现时,它会“赶上”它错过的所有办公室。

于 2012-09-04T05:47:46.757 回答