Cron Job for everyday except second Sunday and fourth sunday Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of Cron Job for everyday except second Sunday and fourth sunday without wasting too much if your time.

The question is published on by Tutorial Guruji team.

What will be the cron job for scheduling a script for every day except second Sunday and fourth Sunday of the month.

Thanks

Answer

Although I think it’s a bad idea and it would be better to run it every 14 days, this should do what you want. (To run at 4:00 at night)

0 4 1-7   * *    test $(date +%u) -eq 7 && ./yourscript.sh
0 4 15-21 * *    test $(date +%u) -eq 7 && ./yourscript.sh
0 4 22-31 * *    test $(date +%u) -eq 7 && ./yourscript.sh

Edit: I forgot to add minutes -> fixed

We are here to answer your question about Cron Job for everyday except second Sunday and fourth sunday - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji