How to Run Linux cron Job at the End of Every Month

Submitted by admin on Thu, 09/15/2016 - 20:32

Edit /etc/crontab
vi /etc/crontab

Every end of the month
H 23 28-31 * * /usr/bin/test $( date -d '+1 day' +%d ) -eq 1 && <COMMAND>

Every last Friday of the month
0 0 * * 5 /usr/bin/test $( date +%m ) -ne $( date --date '7 day' +%m ) && <COMMAND>

These will be useful in Jenkins.
/usr/bin/test $( date -d '+1 day' +%d ) -eq 1

or
/usr/bin/test $( date +%m ) -ne $( date --date '7 day' +%m )

Tags