Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am trying to manually set the computer's time in VirtualBox but it always resets itself to what it was before I changed it. How can I disable ntp and tell the system what time I want it to be?

share|improve this question
    
Can you give some more details about your problem? Whattime do you want it to be and what time sets your computer? –  qbi Apr 17 '11 at 7:05
    
I want to set an arbitrary wrong time on my computer. –  Jeremy Bicha Apr 17 '11 at 7:11

6 Answers 6

up vote 8 down vote accepted

As mentioned in another answer, if you are running Ubuntu as a Guest under VirtualBox then you should be aware that the system time is automatically kept in sync by the Guest Additions (i.e., not through an option in the motherboard settings).

Your solution in that case is to disable the Guest Additions, which can be achieved by executing

sudo service vboxadd-service stop

or

sudo /etc/init.d/vboxadd-service stop

You can then set the time as desired (from command line using date --set or using the system settings applet)

The VirtualBox service will be restarted at next reboot, or you can do it manually.

share|improve this answer
    
Off topic, but disabling/uninstalling Guest Additions allows you to set the system clock on Windows guest OSes as well –  speckledcarp Feb 18 at 21:14

Well, if you want to set arbitrary dates, first you should disable or deinstall ntp.

  • To disable it, open a terminal and run sudo update-rc.d -f ntp remove
  • To deinstall it, use your favorite software management software

After that you can use the date-command to set your system time:

date -s "17 April 2011 12:34:56"
date --set="17 April 2011 12:34:56"

Both commands are equivalent. To only set the time you can use:

date +%T -s "12:34:56" 

The date-manpage has some more format controls. You can use them all to change the date

share|improve this answer
    
Ok, I've done that but sudo date -s only holds the date for a few seconds before reverting. By that, I mean, running date again shows the time I set working normally but the time indicator in the panel does not, and when I run date again, the time has switched to match the panel clock.....And trying to change the indicator-datetime clock doesn't work either. I think I'm going to have to open a bug. –  Jeremy Bicha Apr 17 '11 at 18:23
    
Are you sure that deinstalled/disabled ntp? Do you some other automatic time management software (i.e. chrony) installed? –  qbi Apr 20 '11 at 19:33
    
It's a new Natty install in VirtualBox and I purged anything ntp and did not install any other time management software. –  Jeremy Bicha Apr 21 '11 at 0:40
1  
Virtualbox „transfers“ the time from your host to the client. You'll have to change some options here. Maybe virtualbox.org/manual/ch03.html#settings-motherboard is helpful. –  qbi Apr 21 '11 at 22:40
    
thanks for solving my problem. –  Jeremy Bicha Apr 22 '11 at 5:06

Click on the time & date section of the panel, then the Calendar will appear and underneath that the Time & Date Settings is there so click that.

Click on the Padlock icon and enter your password, then choose Set The Time to manually.

share|improve this answer
    
I'm going to go ahead and mark this as the best answer for most users. My specific problem was with VirtualBox. –  Jeremy Bicha Apr 24 '11 at 6:34

I have found a solution. Read the following material: link

Basically if you have Windows host and Ubuntu guest, do the following:

  1. Find a name of you VM (Virtual Machine) - run VB, select your VM, open settings, in 'General' tab check the name, e.g. in my case Ubuntu 12.04 32bit
  2. In Windows, start a command line interpreter, go to `C:\Program Files\Oracle folder and click VirtualBox to select, then holding left shift key, do a mouse right-button click and select "Open command window here" menu, the interpreter has to be running now
  3. Paste the following command (change the VM name to your name!):

    VBoxManage setextradata "Ubuntu 12.04 32bit" "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" 1

  4. Finally, start your Ubuntu guest and set the time and date manually.

share|improve this answer

In the Software Center look up ntpdate and remove it, or in terminal: sudo apt-get remove ntpdate

(You may have to reboot to fully disable ntp)

Then set your date.

share|improve this answer
    
Ok, I purged ntpdate and rebooted but I'm still unable to set the system clock and have it stick. –  Jeremy Bicha Apr 17 '11 at 7:12

The only way is to set the time in the Virtualbox motherboard using the command line:

VBoxManage modifyvm <name> --biossystemtimeoffset <msec>

For example, to set back the date 1 year:

VBoxManage modifyvm <name> --biossystemtimeoffset -31536000000
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.