Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sometimes it is possible to trick a Linux app by calling it like this:

HOME=/tmp/foo myapp

This would make myapp think /tmp/foo is the home directory, it won't try to get the user id, find its home directory via getpwent().

This is useful when myapp must be forced to dump some of its config files into a non-standard location different than ~.

A similar trick can be done like this:

LANG=foo LC_ALL=bar myapp

This is useful when myapp needs to be called once with a different locale without having to make the change persistent by using the export bash built-in or even modify stuff in /etc/profile.

Is it possible to pull the same trick with time and date? The goal is to make an app use another time than the system ones. The final goal - to make timestamps that appear in logs/commit messages not being tied to the system time.

share|improve this question
    
+1 on the question because it's an interesting idea with interesting use cases that I'd never considered. I'm just sorry I can't provide an answer. –  Doug Harris May 21 '10 at 17:37
    
For moderators: feel free to mark this question as duplicate of the one mentioned by Dennis Williamson in his answer. –  geek May 21 '10 at 17:52
    
Cross-site duplicates are not usually closed. –  Dennis Williamson May 21 '10 at 19:02

1 Answer 1

up vote 2 down vote accepted

This answer from Stack Overflow suggests a library called libfaketime.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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