Run Bash script on Monday of month


Sometimes there are needs to run a bash script on the first monday of every month.
This can be easily achieved.

Create crontab entry to run script every monday:

00 09 * * mon /script.sh

now in the script add the check for the first monday of month:

#!/bin/bash

# get date in correct format
number=$(date +"%u%d")
# make an if to only run on first monday
if [ ${number} -le 107 ] ; then

# add some code here

fi
,

Leave a Reply

Your email address will not be published. Required fields are marked *