I want to run a rsync in a cron job.

The rsync task is :

rsync -avz -e "ssh -i /home/mypc/.ssh/bkpRsync" --delete /home/mypc/backup/ root@vpsxxxxx.ovh.net:backup/

It works, when done manually.
But the cron line:

0 */2 * * * rsync -avz -e "ssh -i /home/mypc/.ssh/bkpRsync" --delete home/mypc/backup/ root@vpsxxxxx.ovh.net:backup/

doesn't perform any transfer to the vps. I do have a log that tells that the rsync has been performed though.
I have tried creating the crontab with sudo, thinking that it was a right issue. It didn't help.
I don't understand why the cron task doesn't work.


You're missing the leading slash from your home directory in the crontab command, so you're syncing across to a location that doesn't exist already. You should check whether you've created a backup in /root/home/mypc/backup/ on the VPS which you will probably wish to delete.


0 */2 * * * rsync -avz -e "ssh -i /home/mypc/.ssh/bkpRsync" --delete home/mypc/backup/ root@vpsxxxxx.ovh.net:backup/


0 */2 * * * rsync -avz -e "ssh -i /home/mypc/.ssh/bkpRsync" --delete /home/mypc/backup/ root@vpsxxxxx.ovh.net:backup/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.