TECHIES WORLD

For Techs.... Techniques.... Technologies....

BashLinux

How to configure cronjob to run first Sunday of every month

Cronjob timing fields are not enough to achieve this requirement. But it provides the option to configure conditions in cronjob expressions.

Sample cronjob configuration is given below.

00 10 * * 0 [ $(date +\%d) -le 07 ] && path-to-script

The date +%d command checks the current day, and the script will be executed only if the day is less than or equal to 7. Since the cron is configured to run on Sunday, it runs only on the first Sunday of the month.

That's all…