System Hardware clock and Date Synchronization and Change in Linux
by sahab on May.29, 2010, under RHEL5, Ubuntu, ubuntu 10.04, ubuntu 7.10, ubuntu 8.10, ubuntu 9.04, Ubuntu 9.10
Resetting the Date and Time
The Ubuntu installer queries during installation for default time zone settings, and whether your computer’s hardware clock is set to Greenwich mean time (GMT)more properly known as UTC or coordinated universal time.
Linux provides a system date and time; your computer hardware provides a hardware clock-based time. Ubuntu provides several date and time utilities you can use at the command line or during an X session, including these:
date Used to display, set, or adjust the system date and time from the command line
hwclock A root command to display, set, adjust, and synchronize hardware and system clocks
time-admin Ubuntu’s graphical date, time, and network time configuration tool
Using the date Command
Use the date command to display or set your Linux system time. This command requires you to use a specific sequence of numbers to represent the desired date and time. To see your Linux system’s idea of the current date and time, use the date command like this:
ubuntu@linux-desktop:~$ sudo date
Tue Aug 18 22:34:21 IST 2009
To adjust your system’s time (say, to August 18, 2010 at 8 a.m.), use a command line with the month, day, hour, minute, and year, like so:
$ sudo date 081808002010
Use the hwclock command to display or set your Linux system time, display or set your PC’s hardware clock, or to synchronize the system and hardware times. To see your hardware date and time, use hwclock with its –show option like so:
ubuntu@linux-desktop:~$ sudo hwclock --show Tuesday 18 August 2009 10:42:06 PM IST -0.228789 seconds
Use hwclock with its –set and –date options to manually set the hardware clock like so:
$ sudo hwclock --set --date "08/18/09 23:00:00" $ sudo hwclock --show Tuesday 18 August 2009 11:00:00 PM IST -0.228789 seconds
In these examples, the hardware clock has been set using hwclock, which is then used again to verify the new hardware date and time. You can also hwclock to set the Linux system date and time date using your hardware clock’s values with the Linux system date and time.
For example, to set the system time from your PC’s hardware clock, use the –hctosys option like so:
$ sudo hwclock --hctosys
To set your hardware clock using the system time, use the –systohc option like so:
$ sudo hwclock --systohc
Changing the Time and Date
Ubuntu’s graphical X tool named time-admin can be used to set your system date and time. The client is found in System, Administration, Time & Date; or you can start it from the command line of an X11 terminal window like this:
$ gksudo time-admin &
February 20th, 2011 on 1:47 pm
There are many features in the computer. Some can be identified by just the physical appearance such as through its hardware. But mainly, it can be identified through its inner program.Linux can indicate date and time.
April 10th, 2011 on 2:47 pm
I am running VirtualBox and my ubuntu time started for about the past 2 months now to slow down the system time. But the hardware clock would stay right.
I came here and with your info and in webmin made a cron job. Webmin put it in /var/spool/cron/crontabs with the name root and it looks like this:
“# DO NOT EDIT THIS FILE – edit the master and reinstall.
# (/tmp/crontab.frADQe/crontab installed on Sun Apr 10 05:03:47 2011)
# (Cron version — $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
0-59 0-23 1-31 1-12 0-6 hwclock –hctosys #Set hareware time to system time every minute.”
I set it so every minute it runs. I think this will fix my time on my system.
I can only guess on this 2 core Atom CPU as I add more to Windows 7 that VirtualBox can’t keep up good with system time.
-Raymond Day
February 27th, 2012 on 9:06 pm
Dear sahab, the article is excellent. I want to ask one question that is how can I change the hardware clock from PM to 24 hour format? If it is 12 hour format than scheduling(cron) is not working.
example: */30 08-21 * * 0-4,6 root /status.sh