Sunday, March 16, 2008

Time and Date Setting for Linux

How to set date and time in CentOS

rpm -qa | grep ntp

If not then load the package by YUM
yum install ntp


date (make sure it matches up with the date your timezone is set to)

hwclock (Verify the bios clock matches the system clock)

"Optional Step"

hwclock --systohc (Set the bios clock to match the system clock)

Then you can go about setting up /etc/ntp.conf and starting and running the time daemon ..

hwclock --set --date="10/05/10 14:19:05"

if you have ntp running

ntpdate "server DNS name or IP address"

hwclock --systohc

To keep your time accurate you can create a cron job that executes:(the -w option is the same as --systohc)

ntpdate "server name" && hwclock -w


Synchronizing clocks

Synchronizing your system clock to an accurate time server is important so that you can prove your log files are accurately time stamped. Create a file in /etc/cron.hourly that contains the following:

/usr/sbin/ntpdate -bu -t 3 your-local-gateway

/sbin/hwclock --systohc

No comments:

Post a Comment