0

I need to test my backend with different times without change the code.

1 Answers1

0

Assuming you want to simulate a time change for certain processes without setting the system clock, you could use the FakeTime Preload Library. The technique relies on hijacking the dynamic linker to load a library that overrides the usual C library's date functions.

200_success
  • 4,771
  • 1
  • 25
  • 42
  • Ok, from shell the date is changed, but in mysql Now() is not changed...I want to change it. How could I do it? – fedemiliano May 07 '13 at 20:16
  • To use libfaketime with MySQL, you'll have to edit the MySQL init script to insert the LD_PRELOAD. On the other hand, you've indicated in a comment that you want to change the system time, in which case you shouldn't bother with libfaketime. Just use the "date" command to change the system time. (Then use the "hwclock" command if you need it to persist across reboots.) Make sure that you aren't running anything like NTP that will sync with an external time source. – 200_success May 07 '13 at 23:28