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.
-
1Start with a Virtual Machine, then destroy the VM's time synchronization mechanism. Since you didn't say which Ubuntu release you are using, that's as detailed as I'll get.– waltinatorNov 18, 2020 at 21:04
-
1Probably dupe: Change Ubuntu time and date for specific application– Pixelated FishNov 18, 2020 at 21:49
Add a comment
|
1 Answer
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.