I’ve know libfaketime, previously known as FakeTime Preload Library, for more than four years, but then I discovered a simpler Fluxcapacitor. However, the latter doesn’t work always, for instance, when I was making this video, the time didn’t charge at all.
It describes itself as follows:
libfaketime intercepts various system calls which programs use to retrieve the current date and time. It can then report faked dates and times (as specified by you, the user) to these programs. This means you can modify the system time a program sees without having to change the time system-wide.
With libfaketime, I could speed up at any rate I want:
FAKETIME='+0 x300'
And this is just one feature of many, you can offset the time, relative time, say back in time by 3 hours:
FAKETIME='-3h'
It supports common suffixes. You can set absolute dates which fixing the system clock, meaning you always get the exact same date, for example 2012-12-21:
FAKETIME='2012-12-21 00:00:00'
If you want it continue to tick as a normal clock should, use “start at”, by prefixing the date with @. In this case, it is:
FAKETIME='@2012-12-21 00:00:00'
There is a more advanced time specification as in opening case, you can set an offset and the speeding rate:
FAKETIME='-1y x0.25'
This sets the clock one year ago with speed of 4 times slower, that means it only ticks 1 second every 4 seconds in our normal time.
Beside the rate x, there is also an i as in increment, for example, i2.0 would get time() two seconds each call.
There is more to libfaketime, it has a wrapper command faketime, also some other environment variables, such as FAKETIME_STOP_AFTER_SECONDS.
The README lists its potential uses:
- running legacy software with y2k bugs
- testing software for year-2038 compliance
- debugging time-related issues, such as expired SSL certificates
- running software which ceases to run outside a certain timeframe
- using different system-wide date and time settings, e.g., on OpenVZ-based virtual machines running on the same host
- deterministic build processes.
For me, it’s a very helpful tool to make video with if I need squeeze the running time, I just use it to speed things up accordingly. In that video, it was sped up by 300 times, because the clock only changes its display every 5 minutes, that is 300 seconds. With this tool, I could make it change every second.
libfaketime is written by Wolfgang Hommel in C under the GPLv2, runs on Linux and Mac OS X, was born in April, 2011. The latest commit as of writing is 18f5ec0 (2015-05-21), the last release was v0.9.6 (2014-06-07).
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.