Hi Unixers,
I have a small script that backs up my data on a daily basis. I'm using the same script to backup a monthly backup (full data to be kept for the whole year) and i use this logic for the backup:
I'm checking for first of the month but the requirement from the management is to make the backup run in the last day of the month!
Could you please let me know how would i check for the last day of the month?
(one thought was to add to the month one day and check whether the day became 1 which indiciates that i'm in the last day! The other thought is to check for each month (28, 29, 30, 31) thru if statements! but then how would i check for leap years?)
Thanks in advance.
Regards,
Khalid
I have a small script that backs up my data on a daily basis. I'm using the same script to backup a monthly backup (full data to be kept for the whole year) and i use this logic for the backup:
Code:
# Check whether today is the first day of the month to do a full monthly backup
#
DOW=`date | awk '{ printf $3 }'`
if [ $DOW -eq 1 ]
then
LEVEL=0
BkupType="Monthly"
fi
I'm checking for first of the month but the requirement from the management is to make the backup run in the last day of the month!
Could you please let me know how would i check for the last day of the month?
(one thought was to add to the month one day and check whether the day became 1 which indiciates that i'm in the last day! The other thought is to check for each month (28, 29, 30, 31) thru if statements! but then how would i check for leap years?)
Thanks in advance.
Regards,
Khalid