This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text] shows wrong time when run from cron (off from win7 time by 4 minutes), but gives correct time when run from bash shell

I noticed in more complicated cron jobs that the time shown in logs
was off. I was running various wget processes so I thought it was just
a delay in the network. But I was wrong. It turns out that the time
seen by cron is delayed by 3 minutes 56 seconds (12:03:56 pm instead
of 12:00:00pm). I made a simple bash script called that I ran
from a bash shell and then via cron at regular intervals.
Here is the script:

exec >> "${HOME}/time_stdout.log"
date +'%Y-%m-%d %H:%M:%S'

On the bash shell, the date and time match the date and time shown in
Windows 7. However, cron is a different story. I set to run at
every 0th,15th,30th, and 45th minute of every hour every day as
follows in my crontab:

0,15,30,45 * * * * /bin/bash /home/REDACTED/
>>/home/REDACTED/time_stderr.log 2>&1

the time_stdout.log for entries ran via cron should be

2011-02-25 12:00:00
2011-02-25 12:15:00
2011-02-25 12:30:00
2011-02-25 12:45:00

But I see:

2011-02-25 12:03:56
2011-02-25 12:18:56
2011-02-25 12:33:56
2011-02-25 12:48:57

I am not sure where cron is obtaining the time from and why it is
different from what can be obtained from the bash shell using the same
command. As you well know, the timing of cron must sync with the time
the computer has in order to do reliable scheduling with cron. I do
not know how to debug this beyond what I have done here as I am not a
programmer. So to further help you understand the problem, I've
attached the output of "cygcheck -s -v -r > cygcheck.out"

Attachment: cygcheck.out
Description: Binary data

Problem reports:
Unsubscribe info:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]