How to temporarily set date and time in Linux shell

I want to write some scripting scripts that create some files and execute commands that change behavior depending on the current date. For testing purposes, I would like to change the time to different dates (past and future) and check the behavior.

Is it possible to change the date exclusively for a single shell-session or to trick one application about the current date? - How can I do that?

+5
source share
1 answer

this can be done using the libfaketime program , which is a preload library, i.e. LD_PRELOAD.

+7
source

All Articles