How to handle daylight savings in cron jobs

croncrontabtime zone

I have a cron job on an amazon ec2 machine (Ubuntu 16.04) that is supposed to run at 2:00 AM Central time.

The cron job is scheduled using UTC time. Since Central time is currently UTC-5 (we are in daylight savings time at the moment), it looks like this:

0 7 * * * /home/ubuntu/runetl.sh

So it runs at 7:00 AM UTC, which is correct.

But when we go back to standard time, Central will change to UTC-6, so the job will start running at 1:00 AM Central time. That's not what I want. I want them always to run at 2:00 AM regardless of daylight or standard time.

How can I do that?

Best Answer

Run sudo dpkg-reconfigure tzdata and set local time zone (instead of UTC) you needed. Also setup and run ntp daemon that will synchronize time precisely and will switch between daytime saving time automatically gradually smoothly that is very important for time critical task as billing, email servers.

Related Question