Had to fix all time related issues on a remote RHEL 6 server which runs without any windowing system. Plain ol' command line. Documenting steps here for future reference:
Check to see if your date and timezone settings are accurate:
# date
# cat /etc/sysconfig/clock
The server I accessed had wrong settings for both the commands. Here are the steps I used to correct:
Find out your timezone from the folder /usr/share/zoneinfo
# ls /usr/share/zoneinfo
Mine was pointing to America/EDT instead of Asia/Calcutta
Update and save the /etc/sysconfig/clock file to
# sudo vi /etc/sysconfig/clock
ZONE="Asia/Calcutta"
UTC=true
ARC=false
Remove the /etc/localtime
# sudo rm /etc/localtime
Create a new soft link to your time zone
# cd /etc
# sudo ln -s /usr/share/zoneinfo/Asia/Calcutta /etc/localtime
# ls -al localtime
Now it should show the link to your time zone
Set your hardware clock to UTC
# sudo hwclock --systohc --utc
# hwclock --show
Update your time from a NTP server (Red Hat NTP server used here)
# sudo ntpdate clock.redhat.com
10 Apr 22:08:27 ntpdate[25695]: adjust time server 66.187.233.4 offset 0.004185 sec
Finally verify the date now
#date --utc
Tue Apr 10 16:39:56 UTC 2012
#date
Tue Apr 10 22:09:58 IST 2012
Add the above ntpdate command in your server startup script or in a cron job to automatically set the system time. The list of ntp servers can be found here: https://support.ntp.org/bin/view/Servers/StratumOneTimeServers
Check to see if your date and timezone settings are accurate:
# date
# cat /etc/sysconfig/clock
The server I accessed had wrong settings for both the commands. Here are the steps I used to correct:
Find out your timezone from the folder /usr/share/zoneinfo
# ls /usr/share/zoneinfo
Mine was pointing to America/EDT instead of Asia/Calcutta
Update and save the /etc/sysconfig/clock file to
# sudo vi /etc/sysconfig/clock
ZONE="Asia/Calcutta"
UTC=true
ARC=false
Remove the /etc/localtime
# sudo rm /etc/localtime
Create a new soft link to your time zone
# cd /etc
# sudo ln -s /usr/share/zoneinfo/Asia/Calcutta /etc/localtime
# ls -al localtime
Now it should show the link to your time zone
Set your hardware clock to UTC
# sudo hwclock --systohc --utc
# hwclock --show
Update your time from a NTP server (Red Hat NTP server used here)
# sudo ntpdate clock.redhat.com
10 Apr 22:08:27 ntpdate[25695]: adjust time server 66.187.233.4 offset 0.004185 sec
Finally verify the date now
#date --utc
Tue Apr 10 16:39:56 UTC 2012
#date
Tue Apr 10 22:09:58 IST 2012
Add the above ntpdate command in your server startup script or in a cron job to automatically set the system time. The list of ntp servers can be found here: https://support.ntp.org/bin/view/Servers/StratumOneTimeServers
Thank you , very helpful
ReplyDeleteIt Me Aman,
ReplyDeleteThank you Very much. its make success my 3 days hard work.
Glad you found it useful Aman :)
ReplyDeleteI think the command should be
ReplyDelete#sudo ln -s /usr/share/zoneinfo/Asia/Calcutta /etc/localtime
Yes you are right .. not sure how that got missed :) .. fixed the omission and thanks!
DeleteHey Chetan,
ReplyDeleteyou saved my day. Thank you very much.
Daniel
great to hear that Daniel :)
Deletegreat it works, fine. thanks
ReplyDeletegreat!!!
ReplyDeleteNice guide thanks!
ReplyDeletethank you very much Chetan
ReplyDeletework great!!
lideth :D
welcome
DeleteThank you. This really saved my time.
ReplyDeleteGreat share !!
ReplyDeleteTHANKS SAVED ME HEAPS
ReplyDeleteThank you, very helpful!
ReplyDelete