Agnus Dei (jackal) wrote,
Agnus Dei

How to handle Timezones/Timechange (EDT/EST) crons on Ubuntu

Ubuntu does not honor the CRON_TZ variable the way that RedHat based Linux does.

Therefore you have to do a check for the EDT/EST from for it to work, and if it matches run the command.
You have to put the cron line in twice. Once for EDT and once for EST.

But this way you can control that the cron always runs at the same time regardless of EST or EDT.

/etc/cron.d# more test-cron
# Ubuntu does not recognize CRON_TZ=America/New_York
# Runs at 6am
1 10 * * Mon,Tue,Wed,Thu,Fri root test `TZ=America/New_York date +"\%Z"` = "EDT" && /usr/local/bin/mycommand
1 11 * * Mon,Tue,Wed,Thu,Fri root test `TZ=America/New_York date +"\%Z"` = "EST" && /usr/local/bin/mycommand

  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened