0

Suppose the Time Zone is AEST (Australian Eastern Standard Time) where time leaps from 2AM to 3AM on start, and reverse from 3AM to 2AM on end.

Daylight Saving Time begins at 2am on the first Sunday in October, when clocks are put forward one hour. It ends at 2am (which is 3am Daylight Saving Time) on the first Sunday in April, when clocks are put back one hour.

When the time changes on DST (Winter to Summer), time leaps from 2AM to 3AM. If the job run is scheduled between this timeframe, then the job will not be executed.

01:57:00
01:58:00
01:59:00
03:00:00 <--- job will not run as between 02:00 and 03:00 will disappear 
03:01:00
03:02:00

When the time changes from DST (Summer to Winter), time reverses from 3AM to 2AM. If the run is scheduled between this timeframe, the run will be executed twice.

01:59:00
02:00:00
...
02:57:00
02:58:00
02:59:00
02:00:00 <--- job will be run twice as between 02:00 and 03:00 will repeat 
02:01:00
02:02:00 

As in at and daylight saving time, it looks this is expected. Then what is the possible solutions to avoid job not being run or run twice, while still need to use DST based time? Disable daylight saving time suggests using fixed GMT+N or GMT-N which we cannot use as we need to use DST based time.

Is Cron or timestamp based programming not to be used, and need to have a scheduler that use epoch or UTC?

1
  • this may help you decide if there is a problem or not Commented Oct 25, 2023 at 23:05

1 Answer 1

-1

On option is to run cron under a UTC+10 offset timezone so there would be no DST adjustment. See this question for examples on how to do this.

The other option would be to configure the job to run twice on DST start day:

0  2 *   *   *   /path/to/job
0  3 1-7 oct sun /path/to/job

So it isn't missed when DST starts.

And then in the script you need to check that jobs hasn't run today. One way to do this is to check the date for the time and time zone. I am assuming that 'date +"%a %m %H %Z"' on the end of DST will report:

02:59:00: Sun 10 02 ACDT
02:00:00: Sun 10 02 ACT

so your script can check:

now=`date +"%a %m %H %Z"`
if [ "$now" -eq "Sun 10 02 ACT" ]; then 
    echo "DST ended - not running"
    exit 0; 
fi;

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .