Link to home
Start Free TrialLog in
Avatar of Christian Palacios
Christian PalaciosFlag for Canada

asked on

Oracle Linux Cron Job Runs at Wrong Time of Day

Hi there,

We have a cron job on an Oracle Linux 7 server that should run at 10PM CST every night, but some odd reason, it runs at 3PM MST.  We have checked the cron job details and it does say 21:00, for 9PM.  When I run "date", I get a time that shows CST as the timezone, but the cron job doesn't seem to be checking this.  Anything I should check/configure?

Thanks,
- Christian
Avatar of Tomas Helgi Johannsson
Tomas Helgi Johannsson
Flag of Iceland image

Hi,

Look at this link
https://www.the-art-of-web.com/system/cron-set-timezone/

Hope this helps. :-)

Regards,
    Tomas Helgi
Avatar of Christian Palacios

ASKER

Hi there,

Thanks for the article.  There is a lot of information in it, is the best solution just to add the "TZ=" entry in the cron file?  

-Christian
ASKER CERTIFIED SOLUTION
Avatar of Tomas Helgi Johannsson
Tomas Helgi Johannsson
Flag of Iceland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
As Christian stated, adding TZ= to your crontab file fixes CRON.

This may or may not be sufficient.

To set a machine/process wide timezone, do this...

ln -sf /usr/share/zoneinfo/US/Central /etc/localtime
service cron restart
service ntpd restart

Open in new window


Note: This only fixes timezone... at the server level... for new processes...

Currently active processes, do not change.

To ensure all processes run in the same timezone, a hard reboot is required.
should run at 10PM CST every night, but some odd reason, it runs at 3PM

I'm assuming the server has (displays) the correct time?
David,

Thank you, I will try your suggestion out too.  I tried the TZ= entry in the cron job file, but the file still ran at a different time yesterday.  For your suggestion, I noticed there isn't already a link enabled as /etc/localtime doesn't have anything linked to it.  If I add this link, do I have to for sure restart the server?  If so, I will schedule a time to restart it tonight as it's a production server and I can't restart it during business hours.

Thanks,
- Christian
Thank you Tomas and David.  The TZ= entry in the cron file fixed the issue, and the symbolic link command helped with the entire server.  Everything is working as it should!