I have a script that is in backup.sh file (chmod 775) :
rsync -e 'ssh -p 31234' -avlz --delete --stats --progress --copy-links admin@foo.xen.prgmr.com:/home/admin/rsync /home/myname/rsync/foo/
When I call it manually, everything works well (and I don't have to enter my passphrase). But when I call it from cron, it just doesn't work.
I used the same setup on the computer of my coworker (who has the same access than me) and it works well.
What's wrong?
Best Answer
I have my passpharseless ssh login setup. I use a command like the following:
rsync --delete -auve 'ssh -i /home/red/.ssh/cron_jobs_key' red@othermachine:/source/dir1 /dest/dir2
The key here is "
-i /home/red/.ssh/cron_jobs_key
" where I have setup an ssh login without a password. Otherwise, I would have to enter my ssh key when I login to my local machine. I generated this ssh key specifically for cron jobs.