An easy way to determine if today is the last day of the month is to determine the numerical date for tomorrow. If tomorrow is "1" then you know today is the last day of the month. This holds true for months with 31 days, 30 days or for Feb. with 28.
This will allow you to create a script that executes on a monthly basis.Code:#!/bin/bash MYTZ=`date | awk '{print $5}'` TOM=$(TZ=$MYTZ-24 date +%d) if [ $TOM == 1 ] then echo "Last Day of the month!" # Enter your monthly code here fi
You could also use the /etc/cron.monthly and it will execute at the first of the month (or last, can't remember which) without you having to code for it.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks