Skip to content
Advertisement

Crontab skip run once a week

I have a CRON expression that will run a given command every 8 hours, beginning at 00:00.

0 0,8,16 * * * 

This will run a given commend 21 times a week, however, my goal is to skip one of these 21 runs on a weekly basis. What is the proper CRON expression to skip the first run on Sunday each week at 00:00 (in other words, an expression that will run 20 times per week)?

Advertisement

Answer

Make it 2 lines:

0 0,8,16 * * 0-5 At minute 0 past hour 0, 8, and 16 on every day-of-week from Sunday through Friday.

And

0 8,16 * * 6 At minute 0 past hour 8 and 16 on Saturday.

You can change the day and hour which you want to skip, but there is no way to do this in 1 line as far as I know.

Advertisement