2

This may or may not be the right approach, but it's feasibility was requested of me:

We have a demo server that we update from time to time in order to keep the statistical calculations up-to-date. The only reason we have to do this is some calculations/statistics only show up if they are within the past X days.

It was asked of me if it's possible to stop the system clock on CentOS when calls are made using the UNIX time-stamp. If time were paused, the calculations would be the same every day and we would no longer need to refresh the database with new data.

There are probably other approaches (script to update current data with recent time-stamps, etc), but this request intrigued me and I'm curious if it is possible.

3

I don't think you can pause system time. Lots of programs wouldn't like it anyway, because they generally expect time to go forward. If you paused the time, then any program going into sleep would never wake up.

I don't understand exactly what you're trying to do, but I suspect that faketime would do what you're after. It lets you run programs with a fake time, going forward at the normal rate but with an offset from the real time, or even making time go x times as fast.

If you need time to go forward at a variable rate for these programs, faketime doesn't do it, but it could probably be adapted to do so with a bit of programming. Alternatively, you could run the programs in a virtual machine and set the system time in the VM however you please.

0

There'a a very neat tool called warp that makes it possible to adjust how the time for a given process is to be adjusted in arbitrary ways - e.g. shifted and even scaled! - while the global system time is unaffected. The time adjustment formula is time = time + warp + (time - base) * (factor - 1). Details are described on the warp manpage. The method it uses is to intercept all time information from the system using the DLL preload feature, and technically to be able to link into the time functions calls it requires a dynamically linked program . If that precondition is met you can transparently use it without changes on your executable by just calling warp ... program ... (where the first ... are the arguments for warp to adjust how the time is seen for the subsequent program).

0

Your happy hacky solution is something along these lines (as root):

export NOW=$(date); watch -n1 date --set=\"$NOW\"

But it's probably not a grand idea :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.