Closed patofet closed 2 years ago
Not sure what you are expecting there.
Does it work without Docker?
My guess is that you spawn a subprocess (with prntdate &) but then change the FAKETIME environment variable of only the parent process. Also, the subprocess is started before FAKETIME is initially set, so libfaketime becomes inactive.
You might find it easier to sync faketime settings across process hierarchies using a file (instead of the FAKETIME environment variable), and because you change time settings quite frequently, you might also consider disabling libfaketime's caching.
I'm expecting that the date is correctly synced with the FAKETIME(in reality I have a rust program instead of prntdate) and in this case I try to canche the day in every iteration but in reality I set the correct day. I think that it'll not work because if I set the time before I call the function it'll work as expected. I'll try to use a file and disable caching and I'll see, thanks.
EDIT: I tried the file configuration with:
export LD_PRELOAD=/libfaketime/src/libfaketime.so.1
export FAKETIME_NO_CACHE=1
export FAKETIME='%'
export FAKETIME_FOLLOW_FILE=/tmp/my-demo-file.tmp
export FAKETIME_DONT_RESET=1
prntdate() {
while true
do
date
sleep 10
done
}
prntdate
and the clock only updates when I change the file, is there any way to auto update the time and every 5 seconds set the time?
The file's timestamp is used as a start-at faketime specification. For changing the file's timestamp every x seconds, you'll probably need a separate process with a simple shell script.
Hi, I'm trying to set the date in a docker with alpine and it doesn't work update the date in realtime, I have this example code:
it only prints the actual date and it doesn't have effect the set FAKETIME