Setting up Date & Time in Linux

Sometimes after reboot, Linux Date & Time Settings will go haywire for no apparent reason. It will be delayed for several minutes. I do not know, maybe this happens only to my server. For security reason me office blocks access to port 123 – NTP port.

Server has 2 types of clocks just like any PCs. First is the System Clock and the other one is the Hardware Clock. Take Hardware Clock as PCs CMOS’s clock and System Clock as Windows Clock.

Hardware Clock | Runs forever until your server goes kaput.
System Clock | Runs when your system is running

So, How do you correct Server’s Time & Date setting? This is very important for one of these reasons

  • Troubleshooting – you will need to know when shit happens
  • CRON Jobs – Without correct timing, cron will run at unexpected time.
  • If you are using distributed System – maintaining synchronize time is a must or else – a rogue will mutilate you from behind.\
  • If you are using Daylight Saving…
  • Etc

You must be Root to use this command

Example No.1 : Set Date and Time to 3 JUL 2011 16:00:00

#  date -s "3 JUL 2011 16:00:00"

 

Example No.2 : Set Time Only to 16:00:00

#  date +%T -s "16:00:00"

 

Then run this command

# hwclock --systohc

 

To sync Hardware Clock with System Clock