Commands / Services and tunnels

Services and tunnels

faketime

Also libfaketime, fake clock, time travel

Runs one command as if the clock read another time, without changing any clock.

faketime loads libfaketime into one program, which then answers that program's calls for the time with a shifted one. Nothing else on the machine sees it. It is the honest way to test what a wrong clock breaks: certificates that are not yet valid or expired, tokens and caches that time out.

faketime command usage

faketime -f OFFSET COMMAND
faketime 'YYYY-MM-DD hh:mm:ss' COMMAND

Options

-f -730d
shift the clock 730 days back (+730d ahead; also h, m, y)
'2030-01-01 00:00:00'
start the clock at that moment

faketime examples

faketime -f -730d curl -sS https://bank.lab/
Fetches a page as if it were two years ago: the certificate is not yet valid.
faketime -f +730d curl -sS https://bank.lab/
The same two years ahead: the certificate has expired.
faketime '2030-01-01 00:00:00' date
Prints the date a program would see under a fixed fake time.

Pitfalls

  • A program built statically, or one that reads the time straight from the kernel, is not fooled.

Run it on real machines

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Start with a free account: Google or email, no card.

Open this lab