Crontab 1st Sunday of every Month

You can put something like this in the crontab file:

00 09 * * 7 [ $(date +\%d) -le 07 ] && /run/your/script

The date +%d gives you the number of the current day, and then you can check if the day is less than or equal to 7. If it is, run your command.

If you run this script only on Sundays, it should mean that it runs only on the first Sunday of the month.

Remember that in the crontab file, the formatting options for the date command should be escaped.

As bash script:

# for crontab use 0 8 * * 1 /path/to/script
if  [ $(date +\%d) -le 07]; then
	python spamcannon.py arg1 noattach
else
	echo "Timeframe passed"
fi

Last updated