1

Why does this rsync command running in a cron fail and how to debug it and fix?

unset SSH_AUTH_SOCK && unset KRB5CCNAME && rsync -hvru -e "ssh -p 34503 -i /root/.ssh/id_rsa_rsyncBACKUP" --progress /home/kristjan/* kristjan@192.168.1.213:/BACKUP/Backup/Kundrum/ >> /home/kristjan/logs/rsyncCRON.log

$crontab -l
# Edit this file to introduce tasks to be run by cron.
# m h  dom mon dow   command
0 5 * * 1 /home/kristjan/bin/checkSystem
00 02 * * * unset SSH_AUTH_SOCK && unset KRB5CCNAME && rsync -hvru -e "ssh -p 34503 -i /root/.ssh/id_rsa_rsyncBACKUP" --progress /home/kristjan/* kristjan@192.168.1.213:/BACKUP/Backup/Kundrum/ >> /home/kristjan/logs/rsyncCRON.log
15 23 * * 7 /home/kristjan/bin/unhideCheckSystem

The error is (which I got from a email):

ssh: connect to host 192.168.1.213 port 34503: No route to host

rsync: connection unexpectedly closed
rsync error: unexplained error (code 255) at io.c (235)

The command works if I run it in the shell directly.

EDIT:

from ssh file on remote = AllowUsers kristjan root and cron is run by root

EDIT:

Since posting this question I changed the command and it works that way but I'm still interested in knowing why the first didn't work.

Here is the working command in root's cron:

0 5 * * 1 /home/kristjan/bin/checkSystem
00 02 * * * unset SSH_AUTH_SOCK && unset KRB5CCNAME && rsync -hvru -e "ssh -p 34503 -i /root/.ssh/id_rsa_rsyncBACKUP" --progress /home/kristjan/* kristjan@192.168.1.213:/BACKUP/Backup/Kundrum/ | mail -s "Backup Home report for `uname -n`" myMailATTgmail.com

EDIT because of duplicate flag:

If this was a question about basically doing redirection wrong(not saying I didn't) then why this line in the original question:

The command works if I run it in the shell directly.

0 Answers0