7

We have a VDS running CentOS 5.5 that was created and configured with the EDT timezone. I have replaced etc/localtime with a link pointing to the Australia/Melbourne (UTC+10) timezone file. Running the date command displays the correct date and time.

The problem is that cron jobs are being run as if the server was still using the EDT timezone, even after a reboot. e.g. A job that should have run at 1:01AM just ran at 3:01PM.

What have I missed?

4
  • Do you mean that in crontab -e you have 01 01 * * * * and it actually runs at 01 15 * * * *
    – Paul
    Sep 23, 2011 at 5:50
  • Run date from cron and see what time zone it shows. Sep 23, 2011 at 5:57
  • @Paul, yes that's exactly what I mean. Sep 23, 2011 at 8:07
  • @Pawel, that test revealed cron is definitely still using EDT. quanta's answer solved the problem. Sep 23, 2011 at 8:18

2 Answers 2

4

After changing the time zone, restart the crond service is enough, no need to reboot. Don't know why your cron is still using the EDT timezone, but insert a below line before your cron line:

TZ=Australia/Melbourne
* * * * * ...

and try again.

2
  • This works, although I'd still like to understand why it should even be necessary. Sep 23, 2011 at 8:15
  • It shouldn't be necessary, but if you change the timezone of your server, you need to restart cron so that it knows of the change.
    – jackbravo
    Jan 23, 2015 at 14:33
2

I had the same problem - after I changed the system's timezone, cron's log entries were in the old timezone, even after restarting crond. Then I noticed that ALL log entries were off - messages, mail, and any other programs using syslog.

service rsyslog restart

The first thing syslog does is log a message (naturally enough), so I was able to see that it had the correct timestamp. I restarted crond, just to be sure, and its log entries were correct, as well.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .