Linux clock shows invalid time (UTC vs Localtime problem)
In a Linux multi-boot system it often happens that one distro shows correct system time and another does not. The problem is in how the startup scripts interpret the hardware (BIOS) clock when setting the OS time (the so called System Clock).
If you want to learn more about this (and fix this problem PROPERLY!) – here’s an excellent article on the subject: http://www.linuxsa.org.au/tips/time.html.
Below I am offering a “quick and dirty fix” for the impatient one 🙂
1. Make sure /etc/localtime is a symlink to your correct TZ file (which will be found somewhere in /usr/share/zoneinfo/…).
2. Make sure your correct TZ is specified in /etc/sysconfig/clock, e.g. ZONE=”Europe/Rome”
3. Depending on whether you intend to keep your hw (BIOS) clock in UTC or locatime add UTC=true or UTC=false to that file.
4. Execute hwclock and note what it tells you:
# hwclock
Tue 20 Sep 2011 01:26:34 PM EEST -0.422645 seconds
Let’s assume that the time shown above (as your local time) is actually the time kept as UTC, and that your correct local time would be +3hrs = 03:26:34 PM or 15:26:34.
So you need to set the hwclock with the correct time. So you set the hwclock to the correct (local!) time by using the above time string and changing the time to the correct time:
hwclock --set --date="Tue Sep 20 16:08:49 EEST 2011
At this stage you need to press the RESET button on your computer.
So… If you don’t want to take chances with your data then don’t do it – follow the link I gave above, read the article and do the “proper” fix. Now… chances are… on a newly installed system, with no heavy processes running in the background accessing the harddisks – nothing bad will happen. But, then, hey – you know best if this is a risk you want to take so in the end it’s your call 😉
-
Categories
- Android Development
- Bash
- C programming
- dpkg/apt-get
- drupal
- Emacs
- Git
- Java
- Linux administration
- Linux device drivers
- Linux Gaming
- Linux kernel
- Linux Networking
- Linux on Windows
- Linux printing
- Linux sound and ALSA
- Package Managers
- Programming
- RPM
- Shell and environment
- Tips and tricks
- Uncategorized
- VirtualBox
- Virtualization
- web development
- wine
- WMaker
- Wordpress Tips
- X Window System
- XFCE
-
Articles
- August 2020
- August 2019
- May 2019
- July 2017
- February 2017
- January 2017
- November 2016
- October 2016
- September 2016
- August 2016
- July 2016
- June 2016
- April 2016
- March 2016
- December 2015
- November 2015
- September 2015
- June 2015
- May 2015
- April 2015
- March 2015
- February 2015
- January 2015
- December 2014
- October 2014
- February 2014
- January 2014
- November 2013
- October 2013
- June 2013
- April 2013
- March 2013
- February 2013
- January 2013
- December 2012
- October 2012
- August 2012
- July 2012
- June 2012
- May 2012
- April 2012
- March 2012
- February 2012
- September 2011
- August 2011
- June 2011
- May 2011
- April 2011
- March 2011
- February 2011
-
Meta
Cloud
audio bash boot compile C programming cups drupal emacs etc Fedora git grep how to httpd init kernel libc linux linux partition localtime login make mount mp3 mysql networking oracle package managers password phpMyAdmin programming rpm shell sql vbox version control system virtual box vm web server wordpress www xargs xfce xwin yum