Wednesday, July 1, 2015

Cron error

Error in cron log

tail -f /var/log/cron

Dec  3 00:21:01 lfvsfcp25961 crond[19203]: (root) CMD (/home/root/backup/backup.sh backup.pg.com)
Dec  3 00:23:01 lfvsfcp25961 crond[24488]: (root) CMD (rsync -av --progress --inplace -e "ssh -i /home/root/.ssh/backup_rsa -q -c arcfour" /data/backups/`date +")


actual cron entry

23 00 * * * rsync -av --progress --inplace -e "ssh -i /home/root/.ssh/backup_rsa -q -c arcfour" /data/backups/`date +"%Y%m"`* root@backup.pg.com:/data/backup/backups > /tmp/sync.log


Fix:
escape the % signs. They have a special meaning in crontabs:

man (5) crontab:

Percent-signs (%) in the command, unless escaped with backslash (\),
will be changed into newline characters, and all data after the
first % will be sent to the command as standard input.

23 00 * * * rsync -av --progress --inplace -e "ssh -i /home/root/.ssh/backup_rsa -q -c arcfour" /data/backups/`date +"\%\Y\%m"`* root@backup.pg.com:/data/backup/backups > /tmp/sync.log

No comments: