Cron, not as easy as expected? amis conclusion

Cron, not as easy as expected?

Few days ago I was confronted with the situation that a refresh job failed. The job is supposed to run every Saturday morning at 07:00, but failed due a configuration change. No problem, these things happen in the real world.

The normal cron entry:

00     07     *     *     SAT     /apps/refresh.sh

Saturday evening, I noticed that I did not receive the “I’m completed email”, so had a quick look at what happened. I found the issue, fixed it and added an extra scheduled job for Saturday evening in the crontab. To be sure my rescheduled job would only once I decided to add the date:

25     21     8    12     SAT     /apps/refresh.sh

Before you continue to read, please try to decide for yourself when you expect this job will be executed.

Cron, not as easy as expected? AcbjL9g9i 1

But now the catch: The next evening (Sunday) the job was starting again and failed after several hours due to a backup which was running at the same time. So we ended up with a unusable refreshed environment ☹.

This left us with  a puzzle: why was the job executed on Sunday evening again? Investigating logfiles, check modification timestamps in cron, checking with collegues. Nobody touched the system during the weekend, what happened?

But after some conversations we could only think of the crontab entry which did not work as we thought it would be. Adding the crontab entry at https://crontab.guru/ did provide the explanation on my puzzle:

Cron, not as easy as expected? 2024 12 11 08 21 44 Crontab.guru The cron schedule expression generator

In my attempt to prevent more then once executing I added the date. But this date was Sunday (dec. 8th 2024) instead of Saturday. Resulting that the job would be running on December 8th and on every Saturday in December.

Did you know that?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.