Quantcast
Viewing all articles
Browse latest Browse all 5991

Schedule crontab job for last sunday in the month [closed]

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?


Viewing all articles
Browse latest Browse all 5991

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>