Cron – Setting Timezone for Cron Jobs in CentOS5

centos5crontimezone

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?

Best Answer

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.

Related Topic