Header Shadow Image

Set or synchronize date and time on your Linux/Unix installation.

Having a dual boot system, I find that when setting one OS time correctly will corrupt the other OS's time. This has been going on for a while on my system despite numerous attempts to set the time properly. I suspect this has to do with BIOS settings but couldn't pin point the correct one when I started to look into the issue. To that end, and in the process, I managed to find some useful commands to work with to try and fix this issue on my system. Here's one for instance to synchronize your time with time from a remote server:

/usr/bin/rdate -s cs.cmu.edu >/dev/null 2>&1

Optionally I could also add this to one of the 'rc.local' files and have it set my time according to 'cs.cmu.edu' or yet another 'rdate.darkorb.net' correctly each time. However now 'hwclock' and 'date' now showed two different and conflicting times:

$ hwclock
Tue 25 Dec 2007 06:01:27 PM EST -0.045184 seconds
$ date
Tue Dec 25 22:59:37 EST 2007

After another check, I followed up on the above by running 'clock -w' to synchronize the hardware and OS times:

$ clock
Tue 25 Dec 2007 06:01:59 PM EST -0.080102 seconds
$ hwclock
Tue 25 Dec 2007 06:02:0
$ hwclock
5 PM EST -0.432841 seconds
$ date
Tue Dec 25 23:08:04 EST 2007
$ clock -w (For universal time use 'clock -wu')
$ date
Tue Dec 25 23:08:09 EST 2007
$ clock
Tue 25 Dec 2007 11:08:14 PM EST -0.186280 seconds

Unfortunately '-w' to 'clock' doesn't come up in the 'man' pages or when using '–help' on my distribution. Your mileage may differ. If you have a dual boot system as I do, you will need to set your BIOS time and date to the local time and date NOT UTC. The reason for this is that Windows reads BIOS time directly (For Windows BIOS time is always local time). So set BIOS time to local time NOT UTC to allow Windows and Linux to function correctly on a dual boot system. Below are a couple of other things you can look into as well if you continue to have issues setting time: Set the hardware clock to a date/time:

hwclock –set –date="12/31/2000 24:59:59"

Couple of notes on commands 'hwclock', 'clock', 'date', 'time' or 'setclock' and others you may have not already in this list:

  • /etc/sysconfig/clock holds settings for the hardware clock (UTC or local time)
  • Symlink /etc/localtime to a zone in /usr/share/zoneinfo/… to set the timezone. (To get a list of zones available on your distribution run 'ls -altr /usr/share/zoneinfo/*|grep "^/"')
  • Set current system date/time by running 'date MMDDhhmm'.
  •  Type '/sbin/hwclock –systohc [–utc]' to set hardware clock.
  • Another file you can look into is "/etc/rc.sysinit" that also sets the clock at startup and may provide more clues if your date/time still are not set correctly.

On Fedora systems, I also stumbled on the 'timeconfig' command line text GUI utility for setting the time but this too had the same effect on synchronizing the time between Linux, my Hardware and Windows to the same thing.

Other tools in your arsenal include:


which is a graphical tools particularly in KDE 4.X.  Using the /usr/bin/system-config-date over date –date="2010-02-14 00:39:42 EST" worked as well.  Here's the equivalent with date:

# date; date –set="2010-02-14 01:10:42";date
Sun Feb 14 01:11:52 EST 2010
Sun Feb 14 01:10:42 EST 2010
Sun Feb 14 01:10:42 EST 2010


Unfortunatley in my case this issue looks to be more hardware/BIOS related then anything else since regardless of the above, my Windows time and Linux time still differed (following subsequent reboots to test) but using the above, I could effectively set my time.

UPDATE: Aug 29 2011 03:50 PM EDT

Years later, new motherboard, CPU system yada yada and here's my steps (Date problem fixed):

# date –set="2011-08-29 15:45:45"
Mon Aug 29 15:45:45 EDT 2011
# date
Mon Aug 29 15:45:49 EDT 2011
# hwclock
Mon 29 Aug 2011 11:51:10 PM EDT  -1.000406 seconds
# hwclock; date
Mon 29 Aug 2011 11:51:15 PM EDT  -0.422428 seconds             (HW clock still off.  If I set HW clock first, it reverts to date time)
Mon Aug 29 15:45:57 EDT 2011
# hwclock; date
Mon 29 Aug 2011 11:51:21 PM EDT  -0.297455 seconds
Mon Aug 29 15:46:03 EDT 2011
# clock -w
# hwclock; date
Mon 29 Aug 2011 03:46:09 PM EDT  -0.953539 seconds
Mon Aug 29 15:46:09 EDT 2011


Good Luck!

Leave a Reply

You must be logged in to post a comment.

  Copyright © 2003 - 2013 Tom Kacperski (microdevsys.com). All rights reserved.

Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 Unported License