crontab hour with UTC working hours GMT-8

Tag: cron , crontab , utc , gmt Author: thewiner Date: 2012-12-25

i have a machine set in GMT. i would like to have a cron task scheduled from 6AM to 5PM in PST, which is GMT-8.

gmt time zone. typical.

00 06-17 * * * 

now -8 produces a crontab bad hour error.

00 22-09 * * *

the following is accepted or should i say, no error.

00 22,23,0,1,2,3,4,5,6,7,8,9 * * *

any short form therefore?

Best Answer

For vixie cron,

Lists and ranges are allowed to co-exist in the same field. "1-3,7-9" would be rejected by AT&T or BSD cron -- they want to see "1-3" or "7,8,9" ONLY

That is, the following:

00 22-23,0-9 * * *

Other Answer1

You can try by changing the time zone for cron also:

[email protected]:~$ crontab -l | tail -2
TZ=Africa/Tripoli
*   *   *   *   *   date > date.txt
[email protected]:~$ cat date.txt
Thu Jan 10 18:50:01 EET 2013
[email protected]:~$ date
Thu Jan 10 22:20:19 IST 2013

comments:

interesting cool idea. thnx

Other Answer2

A good place to try out the basics is the cron simulator at www.dataphyx.com 1