Script is meant to be used with other scripts in order to determine if it is the last day of the month. Useful for making sure a particular script runs at the end of the month. Just add a cron job that checks this every day at the time you would want your code run if it was indeed the last day of the month.
Need assistance with tax planning? Discover how our specialized services can benefit your finances
2 0 * * * /usr/bin/last-day-of-the-month.sh
#!/usr/bin/bash # last-day-of-the-month.sh # By: Scott Rowley # http://www.sudobash.net/ ######################################### TODAY=`/usr/local/bin/date +%d` TOMORROW=`/usr/local/bin/date +%d -d "1 day"` # See if tomorrow's day is less than today's if [ $TOMORROW -lt $TODAY ] then echo "Today is the last day of the month, running code…" /run/your/code fi exit 1