AnswerBun.com

Cron Job for everyday except second Sunday and fourth sunday

Unix & Linux Asked by Tim_drake931 on January 3, 2022

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

Thanks

One 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

Answered by Garo on January 3, 2022

Add your own answers!

Related Questions

How to expand “word” in bash? Not talking about file wildcards

2  Asked on October 31, 2021 by luis-santos

     

Parse a string using keywords

7  Asked on October 31, 2021 by beaker

       

Why does the command a-=2 fail?

4  Asked on October 31, 2021 by tmpbin

   

Shell dropping every other character of input

3  Asked on October 31, 2021 by michael-davis

         

Out of memory, but swap available

1  Asked on October 31, 2021

       

How can I display list of files in a directory?

4  Asked on October 31, 2021 by brocharvey

   

Booting from ISO suddenly stopped working

0  Asked on October 31, 2021 by ajgringo619

       

Does Pulseaudio leak memory?

2  Asked on October 31, 2021

     

Ask a Question

Get help from others!

© 2023 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP