The Ubuntu server's current date and time is different from the time zone date and time. I have tried using:
sudo date "30 Sep 2015 4:43:42"
to change it but it did not change the date and time, just printed on terminal the date and time I changed, but when I executed:
sudo hwclock --show
The date and time is still the old one.
What is the correct way to change date and time of Ubuntu Server?
Best Answer
You can set the system date with this command:
Then when using
date
, it should be showed correctly.Now you should also the set hardware clock in the BIOS of the system, that the setting persists over a reboot (dureing the startup the system time is set to the value of the hardware clock). Do that with
hwclock
:This gets the system clocks (sys) value and sets the hardware clock (hc). Check it with the
hwclock
command. Bothhwclock
anddate
should now show the same date and time.To set your timezone, you can use this command:
BTW: If you use a this machine as a server, I strongly recommend using an NTP-Client to sync the time over network. So you can guarantee that all your servers have the exactly same time set. This will sync the time while the machine runs. If you have applications which are dependent of synced time over server, I recommend the NTP-Daemon. The longer it runs in the background, the more precise is the time.