How can I make cron jobs run on GMT, not local time?

this is my crontab file:

#m  h           d   m   wday    command
TZ=GMT
5   0,6,12,18   *   *   *   ~/Documents/bash/transfer.sh

my jobs seem to be running at the local time (GMT+11) I am running os x snow leopard, but will move the code onto linux when development is complete.

The linux environment may be a shared environment where I may has less control over configuration.

link|improve this question
feedback

2 Answers

Not all versions of cron support running jobs using a time zone other than the system's.

If yours does, it's likely that the specification should be TZ=GMT or TZ=UTC (without the angle brackets). In some cases, the variable would be CRON_TZ.

The best thing to do is check the documentation specific to the particular system. See man 5 crontab.

link|improve this answer
feedback

You perhaps could wrap the original crond binary.

mv /usr/sbin/crond /usr/sbin/crond.real
cat > /usr/sbin/crond
#!/bin/sh
TZ=GMT
export TZ
exec crond.real ${1+"$@"}
link|improve this answer
hello hlovdal, could you please explain these steps? – compound eye Feb 24 '11 at 23:46
Are you copying crond to crond.real, then replacing crond with a short script, in which you set and export TZ, then execute crond.real? – compound eye Feb 24 '11 at 23:55
Not copying but moving, but yes the rest of your analysis is correct. – hlovdal Feb 25 '11 at 3:17
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.