How to execute a script every 1st Saturday and 3rd Saturday of a month
I have a requirement to execute a script every 1st Saturday and 3rd Saturday at 8.30 AM. I am new to using the cron job in Linux. Please let me know if the following will work.
30 8 1-7,14-20 * * [ `date +\%u` = 6 ] && /path/to/myscript
Taking into consideration
- First Saturday falls between 1 - 7
- Third Saturday falls between 14 - 20
The cron job should run on every one of those days and immediately exit if it's not Saturday.
Please advise.
You can probably simplify this down to:
30 8 1-7,14-20 * 6 /bin/bash /path/to/script
As per Crontab.guru, this will run At 08:30 on every day-of-month from 1 through 7 and every day-of-month from 14 through 20 and on Saturday.