Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

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.

share|improve this answer

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+"$@"}
share|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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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