Search notes:

Shell command: faketime

faketime manipulates the system time for a given command.

-f option

Without the -f option, faketime parses the given timestamp like date does with -d.
With the -f option, faketime passes the given timestamp to libfaketime for some additional features.

Simulate »five days ago«

date
# Mon Feb 13 11:00:38 CET 2017

faketime -f "-5d" date
# Mon Feb  8 11:00:38 CET 2017
Github repository shell-commands, path: /faketime/five-days-ago.sh
Time units are y for years, d for days, h for hours and m for minutes.

Speeding up clock

#
#  Speeding up the clock four times.
#
#  The sleep 1 takes only a fourth of a second in real time.
#
faketime -f   x4   /bin/bash -c 'while [ $SECONDS -lt 3 ]; do echo $SECONDS; sleep 1; done'

# Output:
#
# 0
# 0
# 0
# 1
# 1
# 1
# 1
# 2
# 2
# 2
# 2

Github repository shell-commands, path: /faketime/speed-up-clock.sh

Freezing clock

faketime -f "2001-02-03 04:05:06" /bin/bash -c 'date; echo "press enter"; read nl; date'
Github repository shell-commands, path: /faketime/freeze-clock.sh

Starting at specific point in time

faketime -f '@2001-02-03 04:05:06' /bin/bash -c 'while [ $SECONDS -lt 6 ]; do date; sleep 1; done'

# Output
# 
# Sam Feb  3 04:05:06 CET 2001
# Sam Feb  3 04:05:07 CET 2001
# Sam Feb  3 04:05:08 CET 2001
# Sam Feb  3 04:05:09 CET 2001
# Sam Feb  3 04:05:10 CET 2001
# Sam Feb  3 04:05:11 CET 2001
Github repository shell-commands, path: /faketime/start-at.sh

Installing

Ubuntu
$ sudo apt install -y faketime
Arch Linux
$ sudo pacman -S libfaketime

See also

I have once written a similar command line utility for Windows.
date
The datefudge utilities.
Shell commands

Index