I have a strange issue I'm starting to troubleshoot and wondered if anyone would have any helpful tips.

I have a cronjob executed every minute that executes a script and appends the output to a file on a filer. The job prints the current timestamp since epoch (date +%s) and the current uptime uptime (including the current system time) to a file.

The script is:

DATE=`date +%s`
UPTIME=`uptime`
echo "$DATE;$UPTIME"

And what I get is:

1325770921; 14:42:01 up 17 days
1325775379; 14:43:01 up 17 days
1325771041; 14:44:01 up 17 days

Notice how the timestamp in the middle is ~1 hour 15 minutes off.. any ideas as to the cause?


Solution 1:

You mention in the comments that you are running a virtual machine. Virtual machines should have an NTP client running continually correcting for the proper time and date. If you don't do this, the interaction between the physical hardware clock and the virtual clock can get messy and the time will drift.

Really, every system should run NTP, but in virtual machines it is critical instead of just recommended.

Linux and BSD environments should have both NTPd and OpenNTPd available; you didn't mention which environment you are using.