31

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.

Lucio
  • 1,307

1 Answers1

30

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 –  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: http://www.nirsoft.net/utils/run_as_date.html – Denis Fuenzalida Jan 01 '17 at 22:42