Linux runasdate analogue

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:

  1. 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).

  2. Find a wrapper library to do this, or write your own. Some options are given below.

  3. 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.


I had the same problem in finding an alternative to RunAsDate in Linux Ubuntu, and I came to this solution.

I created a launcher of the program that I want use with RunAsDate. If the software if you want to use is called Foo, create a file on your desktop called Foo.desktop, and modify it using gedit or a similar text editor. Then add to it the following lines of code:

[Desktop Entry]
Name=Foo
Comment=Runs the Foo application
Exec=sh -c "sudo date --set '01 Jan 2008 12:00:00'; path/to/Foo; sudo timedatectl set-ntp no; sudo timedatectl set-ntp yes;"
Icon=path/to/icon.png
Terminal=true
Type=Application
StartupNotify=true

You just need to change the Name, Comment and Icon information with your actual resources.

The Exec option changes the system date for the session while you are using the application, then when you finished it automatically resync the system date.