cronjob for first sunday of the every month.

How to set the Cronjob for first Sunday of the every month.
Ans:
You can not set such type of cron by using the cPanel. I have used  following script to set this cron. This script detect the first Sunday of every month and then execute the defined script.
Add the following Cron to execute the “/script/upcp” command first Sunday of every month.
00 00 1-7 1-12 * if [ “$(date +%a) = “Sun” ]; then /script/upcp; fi
OR
You can set it in different format
Create one test script file /home/test.sh
Then enter your script path in the following format into the /home/test.sh file
==============
if [[ "$(date +'%a')" != "Sun" ]]
then
exit 0
else
/script/upcp
fi

==============
And then set the Cron job in following format
00 00 1-7 1-12 * /home/test.sh
Done

Leave a Comment