Rych
Rych

Reputation: 1

Manipulate the system time for a given command

I want to run command with specific date in history. Let say today is 12.Nov.2019 and I need to run one command with date of 10th. Is there any possibility of setting date on fly ?

date -d '1 day ago' /path/to/command 

doesn't work.

Upvotes: 0

Views: 938

Answers (1)

ne3suszr
ne3suszr

Reputation: 83

Use can you faketime to run a command with given time:

faketime - manipulate the system time for a given command

Because you didn't tell us what command and time you want to run, I suppose that you want to run /path/to/command on Oct 10th, 2019.

  • Run /path/to/command in 2 days ago:
faketime -f -2d /path/to/command
  • Run /path/to/command on Oct 10th, 2019:
faketime -f '2019-11-10' /path/to/command

Upvotes: 3

Related Questions