Agnus Dei (jackal) wrote,
Agnus Dei
jackal

How to run crons that are unaffected by EDT/EST time change.

The problem with running crons with UDT is that if you want them to run at the same time relative to East Coast time, you'll have to change all your crons when EST<->EDT time switches. And that's a real pain.

For example, I have a cron that runs at 7 AM every morning. I convert that to UTC and put in my cron as 11 UTC.
Then the clocks change, and guess what? 11 UTC is no longer 7am. It's now 6am instead. And I dont' want my cron to run at 6am. I want it to run at 7am. So I have to go change all my crons to change the hour when EDT<->EST happens.

I found a way around that, that allows me to keep my systems in UTC AND not be affected by EDT<->EST time change.

For example, if you want a cron to run at 11:43AM every day no matter what, he's how:

Example 1 (date prints in UTC):


[root@XXXXXX]# cat /etc/cron.d/cron_test 
# this should run at 11:43 am East Coast time regardless of EDT/EST
CRON_TZ=America/New_York
43 11 * * * root date >> /var/log/cron-test.out

Example 2 (force date to print in EDT/EST time):

[root@XXXXXX]# cat /etc/cron.d/cron_test 
# this should run at 11:43 am East Coast time regardless of EDT/EST
CRON_TZ=America/New_York
43 11 * * * root TZ="America/New_York" date >> /var/log/cron-test.out
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

  • 0 comments