3

Is there a package or a way to run a software with a specific date or time so that when you run it, it uses the date you input instead of your system date.

2

1 Answer 1

3

The faketime command does exactly this.

$ date
Wed Nov 18 16:10:38 EST 2020
$ faketime 'next week' date
Wed Nov 25 16:10:42 EST 2020
$ faketime '1970-01-01 7:30 UTC' date
Thu Jan  1 02:30:00 EST 1970

By default, programs run with faketime still experience the passage of time in the usual way, just starting at whatever time you specify.

$ faketime '2004-10-20 11:06:23 CDT' bash -c 'for i in {1..5}; do date; sleep 1; done'
Wed Oct 20 12:06:23 EDT 2004
Wed Oct 20 12:06:24 EDT 2004
Wed Oct 20 12:06:25 EDT 2004
Wed Oct 20 12:06:26 EDT 2004
Wed Oct 20 12:06:27 EDT 2004

Those examples are with the date command for purposes of illustration, but faketime will run whatever command you specify.

Not the answer you're looking for? Browse other questions tagged .