shellcron

Execute crontab twice daily at 00h and 13:30


I want to execute a script twice daily at 00:00 and 13:30 so I tried:

0,30 0,13 * * *

It seems wrong for me, because like this, the script will fire at 00:00, 00:30, 13:00 and 13:30. Any idea?


Solution

  • You can't do what you want in one entry, since the two minute definitions will apply for both hour definitions (as you've identified).

    The solution is (unfortunately) use two cron entries. One for 00:00 and one for 13:30.

    An alternative is perhaps to execute one script at 00:00. That script would execute your original script, then wait 13.5 hours and then execute that script again. It would be easy to do via a simple sleep command, but I think it's unintuitive, and I'm not sure how cron manages such long running processes (what happens if you edit the crontab - does it kill a spawned job etc.)