Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
    
Do you mean that in crontab -e you have 01 01 * * * * and it actually runs at 01 15 * * * * –  Paul Sep 23 '11 at 5:50
    
Run date from cron and see what time zone it shows. –  Paweł Brodacki Sep 23 '11 at 5:57
    
@Paul, yes that's exactly what I mean. –  John Gardeniers Sep 23 '11 at 8:07
    
@Pawel, that test revealed cron is definitely still using EDT. quanta's answer solved the problem. –  John Gardeniers Sep 23 '11 at 8:18
add comment

2 Answers

up vote 2 down vote accepted

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.

share|improve this answer
    
This works, although I'd still like to understand why it should even be necessary. –  John Gardeniers Sep 23 '11 at 8:15
add comment

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.

share|improve this answer
add comment

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.