We want to extend our backup system to include a monthly end backup. It will be performed the last Sunday in the month but code below is so that I can see it works today on a smaller scale.
Started with (which works)
0 12 * * 0 sudo tar -cpzf /media/BackupDisk/wwwJUNEbackup.tar.gz /var/www
Have trawled the internet and come up with this code, tested in script file
if [ $(date +%d -d '+7 days') -le '8' ] ; then echo "Yes"else echo "No"fi
(For reference this says - if today's date + 7 days is less then or equal to 8 then YES else NO)
But when I try to include into the Sudo's crontrab
26 17 * 6 5 [ $(date +%d -d '+7 days') -lt '8' ] && sudo tar -cpzf /media/BackupDisk/wwwJUNEbackup.tar.gz /var/www
I get a nothing.
What am I doing wrong?