LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-10-2015, 10:45 AM   #1
lemon09
Member
 
Registered: Jun 2009
Location: kolkata,India
Distribution: Mandriva,openSuse,Mint,Debian
Posts: 285
Blog Entries: 1

Rep: Reputation: 37
How to synchronize time between windows and linux


In my machine I have dual operating systems (windows7 and sabayon). After installing the linux I found the time was not correct. I had to change the time zone to get it right.

Then when I got back to windows surprisingly I found that the time in windows have also changed. I changed the time in windows and then when I got back to linux the time has changed.

I just don't understand how to get of the problem. Is there really any way out there to sync the time in both the operating systems.
 
Old 01-10-2015, 10:54 AM   #2
allend
Senior Member
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware-current
Posts: 4,462

Rep: Reputation: 1369Reputation: 1369Reputation: 1369Reputation: 1369Reputation: 1369Reputation: 1369Reputation: 1369Reputation: 1369Reputation: 1369Reputation: 1369
https://wiki.sabayon.org/index.php?t...t_with_Windows
 
Old 01-10-2015, 11:59 AM   #3
Mr. Alex
Senior Member
 
Registered: May 2010
Distribution: No more Linux. Done with it.
Posts: 1,238

Rep: Reputation: Disabled
Your Linux box apparently works in UTC. Windows 7 works in localtime by default. But that can be changed. If you configure your Windows to work also in UTC, it'll make the time synced.

Turn off Internet time sync in Windows and create a file "name.reg" with contents:

Code:
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation]
"RealTimeIsUniversal"=dword:00000001
Run the file and reboot Windows. It works in UTC now.
 
Old 01-10-2015, 12:35 PM   #4
veerain
Senior Member
 
Registered: Mar 2005
Location: Earth bound to Helios
Distribution: Custom
Posts: 2,524

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
Windows thinks the rtc clock (BIOS clock) is set in localtime. So in Windows/BIOS set it to localtime. And in linux while installing set the option that rtc clock is in localtime time and not utc. Howto set after installing linux varies with distro.
 
Old 01-11-2015, 02:50 AM   #5
lemon09
Member
 
Registered: Jun 2009
Location: kolkata,India
Distribution: Mandriva,openSuse,Mint,Debian
Posts: 285
Blog Entries: 1

Original Poster
Rep: Reputation: 37
I just messed it up.

I will just furnish the details. I am new to windows 7 and it is kept only for my siblings. So I prefer not to edit it in windows. I have never faced a problem with time in linux before.
Following are some of the outputs that might help.

Code:
# hwclock --localtime 
Sun 11 Jan 2015 01:08:56 PM IST  -0.172292 seconds
Code:
# hwclock --utc 
Sun 11 Jan 2015 06:39:47 PM IST  -0.984969 seconds
Now the time in the panel shows 06:39 p.m. (this is what is show by hwclock --utc) while the real time over here is 01:08:56 PM (i.e. the time shown by hwclock --localtime).

So, I want to set the system time to local time and how should I do that.
 
Old 01-11-2015, 02:55 AM   #6
allend
Senior Member
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware-current
Posts: 4,462

Rep: Reputation: 1369Reputation: 1369Reputation: 1369Reputation: 1369Reputation: 1369Reputation: 1369Reputation: 1369Reputation: 1369Reputation: 1369Reputation: 1369
From the link in post#2
Quote:
As you can see in the configuration file in the directory /etc/conf.d/, the comment in the file recommends that you edit the file to make CLOCK/clock="local" if you dual boot with Windows. This appears to make sense, given that Windows' clock (the hardware clock) contains local time, so when you boot Linux it will copy the time in the hardware clock to the system clock, find that CLOCK/clock="local" and therefore not make any adjustment to the time in the system clock.
 
Old 01-11-2015, 03:11 AM   #7
lemon09
Member
 
Registered: Jun 2009
Location: kolkata,India
Distribution: Mandriva,openSuse,Mint,Debian
Posts: 285
Blog Entries: 1

Original Poster
Rep: Reputation: 37
I have already made that attempt with no luck. Have a look at the following file:

Code:
# cat /etc/conf.d/hwclock
# Set CLOCK to "UTC" if your Hardware Clock is set to UTC (also known as
# Greenwich Mean Time).  If that clock is set to the local time, then
# set CLOCK to "local".  Note that if you dual boot with Windows, then
# you should set it to "local".
clock="local"

# If you want the hwclock script to set the system time (software clock)
# to match the current hardware clock during bootup, leave this
# commented out.
# However, you can set this to "NO" ifyou are running a modern kernel
# with CONFIG_RTC_HCTOSYS set to y and your hardware clock set to UTC.
#clock_hctosys="YES"

# If you do not want to set the hardware clock to the current system
# time (software clock) during shutdown, set this to no.
#clock_systohc="YES"

# If you wish to pass any other arguments to hwclock during bootup,
# you may do so here. Alpha users may wish to use --arc or --srm here.
clock_args=""
 
Old 01-11-2015, 03:32 AM   #8
allend
Senior Member
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware-current
Posts: 4,462

Rep: Reputation: 1369Reputation: 1369Reputation: 1369Reputation: 1369Reputation: 1369Reputation: 1369Reputation: 1369Reputation: 1369Reputation: 1369Reputation: 1369
Have you rebooted since making the change?
 
Old 01-11-2015, 03:41 AM   #9
lemon09
Member
 
Registered: Jun 2009
Location: kolkata,India
Distribution: Mandriva,openSuse,Mint,Debian
Posts: 285
Blog Entries: 1

Original Poster
Rep: Reputation: 37
Thanks to all of you for your pains. I eventually did it. I will just brief it in case anybody else wants it.

The site
http://docs.slackware.com/howtos:har...tem_local_time
and
https://wiki.sabayon.org/index.php?t...t_with_Windows
were of great help.

Following is the order of the commands that I performed.

Code:
# hwclock -r
# hwclock --hctosys --localtime
# hwclock -r
# hwclock --systohc --localtime 
# hwclock -r
The time in both the operating system is now perfectly synchronized.

Now that it is solved I would like to share my explanation. The command
Code:
# hwclock --hctosys --localtime
I guess have copied the hw clock value to the system clock value as the local time.
Next, the code
Code:
# hwclock --systohc --localtime
would probably have copied the system time to hardware clock as the local time.
So, both the OSs are now synchronized.

Please rectify me if I am wrong.

Last edited by lemon09; 01-11-2015 at 03:43 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How do I synchronize VM guest time with host time PeterSteele Red Hat 3 09-26-2014 01:08 PM
Synchronize time between two linux machines without internet connection sindhu4sind Linux - Newbie 2 06-05-2012 02:05 PM
Synchronize bookmarks between Windows and Linux? General Linux - Software 1 11-15-2007 11:36 PM
synchronize time between linux and XP server taiwf Linux - General 1 11-03-2005 10:52 PM
synchronize linux domain time to workstation sunnyee Linux - Newbie 2 06-25-2004 05:37 AM


All times are GMT -5. The time now is 11:37 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration