Tuesday, January 30, 2024

[SOLVED] Cron Job every second week day

Issue

I need a cron job to run every second weekday for example.

If cron job last ran on a Thursday it should run on the next Monday.

The re-run on Wednesday and again on Friday again and on Tuesday and again on Thursday bring it back to the start.


Solution

Run it every weekday, and have the script set a flag in a file that says whether it did the work the on the previous run. If it did, it skips the work that time and inverts the flag.



Answered By - Barmar
Answer Checked By - Terry (WPSolving Volunteer)