am trying to set up a cron job schedule which is supposed to run from Sun-Fri at 1 PM but on Sat I want it to run at 11 AM. I am trying this URL to create a cron schedule but doesn't seem to figure out how to correctly set it for my scenario.

What I have tried so far: https://crontab-generator.org/ and https://superuser.com/questions/1243513/crontab-run-a-job-once-on-sunday-and-twice-on-the-other-week-days

It seems I can't achieve what I am looking out for in a single command. Is my understanding correct? If not, I would love to see the command.

  • set two jobs ...
    – jsotola
    Nov 3 '21 at 3:20
  • You can do it with a single crontab entry, but that just moves the complexity elsewhere. You could have crontab run the command twice every day, and exit early for the half of the calls that you don't want (you can do that using date and some tests on the crontab line, or in the script itself). Not recommended -- hard to test and prone to errors. You may see this kind of thing done for harder corner cases that cannot be done any other way, like "run this on the last Friday of every month". Nov 3 '21 at 9:58

Use two lines in your crontab instead of one:

Sun-Fri at 1 PM:

0 13 * * 1,2,3,4,5,7

Sat at 11 AM

0 11 * * 6

It's obvious once you see it :) Also, the crontab guru can help.

  • Hello there, I am aware of the two cron solution. I am looking out for a way to achieve this using a single cron expression.
    – Rockstar
    Nov 3 '21 at 20:23
  • @Rockstar: There is no "single cron expression", nor a "single command" that will do that, but even if there were, what possible difference could that make?
    – Seamus
    Nov 3 '21 at 22:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.