This question already has an answer here:
I am making a GFFS backup script for a school assignment but I've encountered some issues with it. It works like this:
/etc/backup/backup.sh PERIOD NUMBER
I have added the following lines in cron:
# m h dom mon dow command # Backup for fileserver: #daily: 5 times/week 0 23 * * 1-5 /etc/backup/backup.sh daily $(date -d "-1 day" +%w) #weekly: 5 times/month 10 23 * * 7 /etc/backup/backup.sh weekly $((($(date +%-d)-1)/7+1)) #monthly: 12 times/year 20 23 1 * * /etc/backup/backup.sh monthly $(date -d "-1 day" +%m) #yearly: each year 0 3 1 1 * /etc/backup/backup.sh yearly $(date -d "-1 day" +%Y)
The calculations at the end is to know what previous backup to override. This works perfect when triggered manually but when triggered by cron it does something weird. i'm talking about the weekly backup entry. the calculation is supposed to give me the week number in the current month. i did 'grep CRON /var/log/syslog' and found this line:
Dec 19 14:33:01 BE-SV-04 CRON: (root) CMD (/etc/backup/backup.sh weekly $((($(date +)
It appears as if cron is not executing the calculation correctly. Any help?