LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how to set the time of the virtual machine same as the host machine (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-set-the-time-of-the-virtual-machine-same-as-the-host-machine-4175531307/)

vjlxmi 01-17-2015 07:00 AM

how to set the time of the virtual machine same as the host machine
 
is it possible to set the time of the virtual machine according to the host system on which it is installed????
i tried to do it by enabling the "hardware clock in UTC time" in the Motherboard tab.. but it is giving me the time in UTC format.. but i want it in IST format.. can anyone help me in this.



Thanks in Advance :)

veerain 01-17-2015 07:25 AM

You should set TZ environmental variabe in /etc/profile.

Try running this command:

Code:

TZ="Asia/Kolkata" date
in command line. See if it shows correct time. If so then set:

export TZ="Asia/Kolkata"

in your /etc/profile file.

joe_2000 01-18-2015 07:48 AM

If the host is a Linux system and runs an ntp service (most distros do by default) you can configure the host as ntp server for the guest.

Assuming that you are using virtual box and a NAT type network adapter for the virtual system the guest will see the host under 10.0.2.2.

In /etc/ntp.conf on the guest system you'll find the section with the servers. I.e. on my machine that looks like below
Code:

# pool.ntp.org maps to about 1000 low-stratum NTP servers.  Your server will
# pick a different set every time it starts up.  Please consider joining the
# pool: <http://www.pool.ntp.org/join.html>
server 0.debian.pool.ntp.org iburst
server 1.debian.pool.ntp.org iburst
server 2.debian.pool.ntp.org iburst
server 3.debian.pool.ntp.org iburst

Make a backup copy of the file:
Code:

cp /etc.ntp.conf /etc/ntp.conf.bck
and then change it into
Code:

# pool.ntp.org maps to about 1000 low-stratum NTP servers.  Your server will
# pick a different set every time it starts up.  Please consider joining the
# pool: <http://www.pool.ntp.org/join.html>
server 10.0.2.2 iburst

The restart ntp (how to do that depends on your init system, worst case just restart the guest system).
Now the two machines should automatically synchronize, provided that the timezone is set correctly as described by veerain.

joe_2000 01-18-2015 08:06 AM

You can probably disregard my previous post. In fact I think virtualbox will synchronise guest and host for you by default...

vjlxmi 01-20-2015 07:37 AM

virtualbox is not syncing the time automatically.Is there any way to sync the time forcefully????

John VV 01-20-2015 12:47 PM

well if you are running on MICROSOFT
the MS windows OS's can NOT use utc
they set the clock on the Motherboard to YOUR LOCAL TIME ZONE!!!
you must DISABLE UTC time on linux

and use the MICROSOFT way of doing things

PS
note
using the microsoft way might cause some "odd" things on the net
dealing with time
such as
a replay to one of your posts might be posted BEFORE YOUR POST

joe_2000 01-20-2015 02:45 PM

Quote:

Originally Posted by vjlxmi (Post 5303915)
virtualbox is not syncing the time automatically.Is there any way to sync the time forcefully????

Not sure if we are talking about the same thing here. When I said syncing I meant "making sure that the minutes and seconds fit together". The hours obviously depend on the timezone.


All times are GMT -5. The time now is 05:21 PM.