run the script for last day of the month

Hello Experts,

I have a script which i want to run the on last day of every month.

let say I have backup.sh script which i want to run it every month last day.

Can anyone please help :confused:

thanks

You could have a script in crontab, that just does the following:

L=$(cal| awk 'END {print $NF}')

Then compare the actual day with $L and decide to run your job or not.
It will run every day in crontab, but only trigger when the comparison is true.

1 Like
1 Like

Hi Jay,

can you please tell me

/bin/date +%d -d "1 day"

what does this -d "1 day" mean in above code.

thanks

Getting Tomorrow's date ..

TOMORROW=`/bin/date +%d -d "1 day"`

Refer the page for GNU date ..

GNU Coreutils