Cron Work Planning

I have two Cron jobs on my web server -

*/5     0-3     *   *   0-4     [my job]
*/5     19-23   *   *   0-4     [my job]

We are in the GMT + 6 time zone, and the server is in the GMT-8 time zone. We would like the work to be done -

Sunday to Friday From 9:00 to 17:00 clockwise GMT + 6 (working time) Every 5 minute interval

But it seems that the cron task works on Fridays, and also stops on Sunday at noon in the GMT + 6 zone.

+3
source share
2 answers

I do not know how easy it is to change the time zone. Some older versions cronsupport an environment variable named CRON_TZ, but the current version crondoes not look.

Thus, you will need to convert time to system time.

, , , . , UTC + 6 UTC + 6 3 , .

:

Sunday 0900-1700 UTC+6 = Saturday 1900-2400 and Sunday 0000-0300 UTC-8
Monday 0900-1700 UTC+6 = Sunday 1900-2400 and Monday 0000-0300 UTC-8
...
Thursday 0900-1700 UTC+6 = Wednesday 1900-2400 and Thursday 0000-0300 UTC-8
Friday 0900-1700 UTC+6 = Thursday 1900-2400 and Friday 0000-0300 UTC-8

crontab :

*/5   19-23   *   *   0   [my job]
*/5   0-3,19-23 * *   1-4 [my job]
*/5   0-3     *   *   5   [my job]

.

, ? crontab?

, root, /etc/init.d/cron TZ=America/Los_Angeles ?

, , . , .

, cron cron?

+2

http://starikovs.com/2011/12/21/cron-timezone-problem/.

  • debian linux dpkg-reconfigure tzdata.
  • /etc/localtime zoneinfo.
  • cron daemon.
+2

Source: https://habr.com/ru/post/1793355/


All Articles