Portal Home > Knowledgebase > Articles Database > Time Zone issue.


Time Zone issue.




Posted by tuxtiger, 11-28-2007, 01:33 PM
Hi all, I have a linux server running websites without any control panels. The problem is that the scripts run by cron daemons are showing up a wrong time and time zone on emails. This happens when they are run as automated scripts by cron daemon. Recently I have changed the time from EST to CST. The command date and hwclock --show gives the correct CST, even the scripts run from the shell showsup the correct CST time. Any help would be highly appreciated.

Posted by wKkaY, 11-28-2007, 02:57 PM
You might find that rebooting the server is the easiest way to get them all agreeing on the timezone

Posted by tuxtiger, 11-28-2007, 03:47 PM
Thanks, Will try it out definetly. This issue occurs only when the cron daemon runs a shell script,the mail send out from the script shows the old time zone. When the script is run on the shell, it looks fine. To be more clear if you give `date`command on an automated script, the old time zone is shown. But if the script is run manually, the correct date and timezone are shown.

Posted by stdunbar, 11-28-2007, 04:10 PM
Can you show the output of an 'ls -l /etc/localtime'? Additionally, if you're on a RedHat based O/S and maybe others, the file /etc/sysconfig/clock contains the system timezone. It sounds like you've got a conflict somewhere.

Posted by tuxtiger, 11-28-2007, 04:33 PM
Here it is. -rw-r--r-- 1 root root 1421 Aug 29 2007 /etc/localtime the content of /etc/sysconfig/clock ZONE="America/New_York" UTC=false ARC=false

Posted by stdunbar, 11-28-2007, 04:52 PM
I'd start by changing your /etc/sysconfig/clock ZONE to "America/Chicago" as I assume you meant Central Standard Time and not China Standard Time, correct? You really need to reboot after that for things to take proper effect.

Posted by tuxtiger, 11-28-2007, 05:03 PM
Thank you. Your help is much appreciated. I mean the Central Standard Time.

Posted by david510, 11-28-2007, 10:33 PM
tuxtiger You have a VPS or a standalone server?

Posted by tuxtiger, 11-29-2007, 01:58 AM
Its a standalone server. You may please quote your opinion on this issue, if you have any.

Posted by david510, 11-29-2007, 02:37 AM
Does this php code output the correct result?

Posted by tuxtiger, 11-29-2007, 12:19 PM
David, the issue is fixed. I have copied the time zone file from /usr/share/zoneinfo and replaced the /etc/localtime. Edited /etc/sysconfig/clock and made correct time zone. Finally synced the system time to hardware clock using hwclock --systohc Thanks for your response.



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
Server Security (Views: 463)