Hari's CornerHumour, comics, tech, law, software, reviews, essays, articles and HOWTOs intermingled with random philosophy now and then
How to set your computer's hardware clock to local time and make Linux recognize it
Tutorials and HOWTOs by
Posted on Sun, Aug 5, 2012 at 13:06 IST (last updated: Sun, Aug 5, 2012 @ 14:19 IST)
Multiple OSes on a desktop or laptop sometimes lead to minor irritations like date/time coordination with the system hardware clock inconsistencies across operating systems.
I had a problem recently when I installed Slackware alongside Debian on my laptop. The hardware clock kept getting reset either by 5:30 hours ahead or behind, depending on which distro I was using. It appears that Debian expected that my hardware clock was set to UTC while Slackware rightly assumed the choice I'd made during the installation (i.e. clock set at local time). Changing the system time every login was getting irritating.
This can be mildly irritating to say the least because you never know if you fixed it properly until you reboot and check every OS. However I think I nailed it at last.
Here's how to fix this issue unless you use NTP to coordinate your date and time with the real world.
- First boot into any one of your Linux distributions.
Login as root or open a superuser terminal and check the current hardware clock with the command
If your hardware clock is not in your local time, then first set the system date to local time in your Linux distro with the command:
date --set "5 Aug 2012 12:54 IST"
Obviously in the above command, the date which you set is your current date and time with the appropriate timezone.
Now synchronize the hardware clock with the current system date and time and indicate that the hardware clock is set to local time with the command
hwclock --systohc --localtime
The above command makes sure that hardware clock time is local time and the distro knows it.
- Now reboot and make sure that the date and time showed in your next login is correct according to your local time.
- Now reboot and check the other distribution. If your date and time is correct according to your local time, there is no other step involved, otherwise repeat the above process again. Now reboot and check each one of your distributions to ensure that the hardware clock is set to the correct local time each time.
I hope the above information has been useful to you. If you find any problems with date and time and you have an internet connection, it might be better to use NTP to keep your clock synchronized with the real world.