How to set the time on a Linux PC
Posted: Mon May 28, 2012 1:08 pm
The Linux Operating System uses the time zone configured to calculate the correct time. So if you have a server in South Africa with the timezone configured as "+2" then it will use the hardware time and add 2 hours.
To set the Operating System time you use the "date" command:
The format is MMDDHHmm
If you also need to set the year you can add the year after all the other values:
The format is MMDDHHmmYYYY
The hardware clock then also needs to be updated to ensure that the system will have the correct time when it is restarted again.
Use this command:
This uses the system time to set the hardware clock.
To set the Operating System time you use the "date" command:
- Code: Select all
date 05281304
The format is MMDDHHmm
If you also need to set the year you can add the year after all the other values:
- Code: Select all
date 052813042016
The format is MMDDHHmmYYYY
The hardware clock then also needs to be updated to ensure that the system will have the correct time when it is restarted again.
Use this command:
- Code: Select all
hwclock --systohc
This uses the system time to set the hardware clock.