Operating System - HP-UX
1832911 Members
2670 Online
110048 Solutions
New Discussion

Cron execution & system time

 
SOLVED
Go to solution
SteveR77
New Member

Cron execution & system time

I have recently run into an issue of my cron jobs exectuing an hour earlier than they are scheduled. However, the log for the crontab posts that it ran at the time which was set in the crontab even though when a date command is executed there is a difference of an hour.

For example the cron post 17:00 for it's execution time but the server's date will show it is only 16:00.

I've stopped and started the cron service, triple checked all the timezone parameters which are set properly to Central time for the US.

I've run out of options to check or try to resolve this so any insight that can be shed is most welcome.
9 REPLIES 9
Dennis Handly
Acclaimed Contributor
Solution

Re: Cron execution & system time

What do these show:
date; date -u
echo $TZ

Did you change /etc/TIMEZONE without restarting cron?
SteveR77
New Member

Re: Cron execution & system time

Results of date commands -

date ; date -u
Fri Aug 21 01:33:03 CDT 2009
Fri Aug 21 06:33:03 UTC 2009

Result of echoing timezone variable -

echo $TZ
CST6CDT

Finally, no to my knowledge there have been no timezone adjustments on this server
Hakki Aydin Ucar
Honored Contributor

Re: Cron execution & system time

it remind of an ambiguous event I faced on our customer Solaris Servers. Problem was very same. Even though I rebooted server not solved issue, but 3 or 5 days later problem solved by the system itself.

I just recommend to reboot server if you are free to do.
SteveR77
New Member

Re: Cron execution & system time

Thank you, unfortunately this server reboots every night but the issue has not corrected itself even after two days.
Dennis Handly
Acclaimed Contributor

Re: Cron execution & system time

> Results of date commands & Result of echoing timezone variable

You seem to have your clock correct.

>even though when a date command is executed there is a difference of an hour.

How do you know this?
Did that date include your timezone?
Can you start a cronjob and do the above date and echo commands?

Note that in a cronjob, TZ isn't likely to be set correctly.

>For example the cron post 17:00 for it's execution time but the server's date will show it is only 16:00.

This implies that cron has TZ set to EST5EDT?

>Hakki: I just recommend to reboot server if you are free to do.

It might be just easier to stop and restart cron:
/sbin/init.d/cron stop
/sbin/init.d/cron start
SteveR77
New Member

Re: Cron execution & system time

The service was stopped and restarted using:
/sbin/init.d/cron stop
/sbin/init.d/cron start

The date does show the timezone correctly as CDT.

I can create a script to capture what cron believes the TZ and time settings are

At this moment, I have reviewed what the environment has for the timezone and all that I could see is correct. Also this server does not do any time synchronization so that is not a variable that could be causing this.

Thanks once again.
Vijaykumar_1
Valued Contributor

Re: Cron execution & system time

Can you pls post your cron entry here..
SteveR77
New Member

Re: Cron execution & system time

Everyone,

Thank you for your assistance. The cron service was getting the default of EDT. While the rest of the environment was CDT.

I'm reviewing the init.d configuration but I believe I have this resolved.
Dennis Handly
Acclaimed Contributor

Re: Cron execution & system time

>The cron service was getting the default of EDT.

My crontab entries set TZ when I start my scripts:
* * * * * export TZ=XX; ...
Or put that in your scripts.