Run a cronjob on every first saturday in a month

I had to remember myself every two months to a specific event. The script of this cronjob sends an email to me to remind me of that event.

57  4 1-7 1,3,5,7,9,11 Sat /usr/home/klamma/bin/remember_vacuum-cleaner.sh

This executes the script on every saturday, if the day matches 1-7 (if the saturday is one of the first 7 days).

Nowaday I use a different setup on my server.

30  3 * 1,3,5,7,9,11 6  /usr/home/dominic/bin/staubsauger.sh

This runs the script on every saturday.
I then process the date within the script and send an email out. If it is actually time for the event (every first saturday) then the email contains information about that event — if it is not time the email contains information about the processed cronjob.

This kind of setup is handy, because you get a testmail every saturday — you see, if your script setup is still working fine ;-)

if [ $HEUTE -gt "7" ]; then
  # do not send
  SENDREPORT='NO'
  #return 0
else
  # send
  SENDREPORT='YES'
fi

This is the part where the script checks whether it’s the first saturday or not.

Leave a Comment