1

I'm working on a product where the business logic changes based on the date and in order to help UAT testing it would be great if we could freeze the date/time on our Linux server.

Is it possible to suspend the date/time on the server from rolling over to the next day ?

Maybe the only way is to create a script which runs daily to adjust the date/time, any thoughts appreciated.

Thanks

JARC
  • 5,288
  • 8
  • 38
  • 43
  • Is the stuff that you want to test just in your programming language - i.e Java? Or do you need to change it in other parts of the system? – teabot Mar 09 '11 at 17:48
  • Well, I quite like this approach for the Java side: http://stackoverflow.com/questions/2001671/override-java-system-currenttimemillis/2001696#2001696 - perhaps you could implement something similar for your Oracle components. By doing so you gain complete control of the temporal dependencies of your tests and don't have to fiddle around with the actual system clock. – teabot Mar 10 '11 at 10:44
  • Interesting, seems overkill for my needs because I don't need this to solve a development testing problem (post adjusted). Will bare in mind for the future though, cheers. – JARC Mar 14 '11 at 13:51

2 Answers2

2

Use LD_PRELOAD and redirect the library functions that retrieve time - An example can be found e.g. here

Erik
  • 88,732
  • 13
  • 198
  • 189
0

I think your best bet is, as you suggest, setting up a script to reset the time. There may be more exotic ways to do this but in the end the result is the same. Just be aware that there will be side-effects to "freezing" the time. Build systems that rely on file modification dates may be confused, as well as daemon processes that assume the clock is always moving forward.

Nack
  • 1,356
  • 2
  • 12
  • 16