We help IT Professionals succeed at work.

CentOS 5.6 Set Date, Time and Time Zone

deklinm
deklinm asked
on
How do i set the time zone, time and date in centos?
Comment
Watch Question

Follow this guide to change the tmezone:

http://www.redhat.com/advice/tips/timezone.html

As for setting the time and date use the "date" command.

http://unixhelp.ed.ac.uk/CGI/man-cgi?date

example:
date --set="Wed Dec 7 17:50:05"
If you want to keep your time accurate, use the network time protocol.

  yum install ntp
  ntpdate <ip address of your time server>

Then you can cron it nightly with something like:

  # set clock each day at 2:15AM
  15 2 * * * root /usr/sbin/ntpdate mytimeserver.net 1>/dev/null

Author

Commented:
I cannot get the time zone to update.  It keeps coming up 7 hours off.  How can I fix that?
What specifically are you using to show the time on the machine - the "date" command?
And make sure that /etc/sysconfig/clock looks good, something like this:


ZONE="America/Chicago"
UTC=true
ARC=false

Open in new window

Author

Commented:
My /etc/sysconfig/clock looks like

ZONE="America/New_York"
UTC=true
ARC=false

However the time keeps coming up as Thu Dec  8 18:26:37 UTC 2011......7 hours ahead

That's because its showing the time in UTC (aka GMT)  The time is correct, it's just not showing it with your zone.

You need to do:
cp /usr/share/zoneinfo/America/New_York /etc/localtime

Open in new window