23

How can I execute a command making it believe that is on a different date than system one?

For instance, if I have this script:

#!/usr/bin/env bash    
date +"%B %d, %Y"

It prints the actual date: march 13, 2014

But I would like it to print a different date, on the future or past, without changing the system date.

If I wasn't clear enough, I want a command line tool like this Windows GUI tool.


I do not want to use a different script (it was just an example).
I do not want to set a cronjob.
I do not want to change my general system date.
Only change the date that apply to the command to run.

23

Using the libfaketime software could be a solution

sudo apt-get install faketime
faketime '2006-09-20' wine Example.exe
  • it did the trick on wine? i tested just on native binaries; cheers – user34720 Jul 12 '13 at 13:19
  • I just tested it with Wine and I got LD_PRELOAD errors on libfaketime.so, so I found a windows tool called RunAsDate which works with Wine 1.6.2 and does the trick: nirsoft.net/utils/run_as_date.html – Denis Fuenzalida Jan 1 '17 at 22:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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