Home » Questions » Computers [ Ask a new question ]

Linux runasdate analogue

Linux runasdate analogue

I want some user (or some process) to have different time and date. Is it possible?

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

"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]

"You can set the TZ to just about any value you want. The system time is unaffected, but the apparent time will change. This is not the same as intercepting the kernel, but requires no coding. Use (3 letter identifier)(offset from UTC h:m:s)[(summer time identifier)(summer offset from UTC h:m:s)]. For example: TZ=XXX[+-]hh:ss:ssYYY[+-]hh:ss:ss the second (summer) set is optional.

date; export TZ=FOO+23:11:17; date; export TZ=; date


Sat Oct 24 20:01:55 UTC 2009
Fri Oct 23 21:01:11 FOO 2009
Sat Oct 24 20:01:55 UTC 2009

Although I may regret this, here is an example program that you could compile to mod your kernel and completely fake out all or just selected programs about the date."