Home » Questions » Computers [ Ask a new question ]

Stop Ubuntu From Automatically Updating the Time

Stop Ubuntu From Automatically Updating the Time

I just need to set the date temporarily. I run this

Asked by: Guest | Views: 316
Total answers/comments: 2
Guest [Entry]

"It sounds like you're really looking for a way to run a program so that the program thinks it's running under a different date and time.

An earlier question was asked about this: Linux RunAsDate analogue? Below is the answer I gave there. Note you seem to be attempting Option 3.

The ntpdate package isn't a daemon and should not be updating your system time automatically (it should run once at boot and no more). I'm not overly familiar with VirtualBox, but I'd guess you've either got ntpd installed or the VirtualBox Guest Additions are syncing the time directly from the host OS, in which case you'll need to disable them, or use one of the wrapper libraries mentioned below in Option 2.

Update: It looks like the VirtualBox Guest Additions install /usr/sbin/vboxadd-timesync -- I'd guess this is the executable that syncs the guest clock with that of the host. Check to see if it's installed a startup script (possibly /etc/init.d/vboxadd-timesync); if so, you can stop the sync with sudo /etc/init.d/vboxadd-timesync stop. If no startup script, you can probably just kill the process.

What RunAsDate does is the following:

RunAsDate intercepts the kernel API calls that returns the current date and time (GetSystemTime, GetLocalTime, GetSystemTimeAsFileTime), and replaces the current date/time with the date/time that you specify.

Under Linux you have some options to accomplish the same thing:

If you can get a Windows version of the program, you might be able to run RunAsDate under Wine (but watch out for a recent bug).
Find a wrapper library to do this, or write your own. Some options are given below.
Use a Virtual Machine. This is overkill, but since an OS in guest VM is completely separate from the underlying host, you can set it's system time to something completely different. It may be quicker to setup than the other options.

Option 2 can be accomplished by different methods, depending on the what you're trying to run. DaveParillo's answer below links to a DIY approach that explains the different methods and includes code for an executable. Some other options include:

datefudge, available in Debian/Ubuntu repositories and other places.
Time-Fake perl module, also in Debian repositories as package libtime-fake-perl.
FakeTime Preload Library (aka libfaketime, freshmeat link), a library that can intercept system calls in dynamically-linked binaries. Available in Debian repositories for Squeeze and Sid."
Guest [Entry]

Quick Answer: Disconnect your network connection :)