Backup with rsync works but not in crontab

Using this command in rsync:

rsync -azvh pi@192.168.1.45:/media/PNY/video /home/john/Desktop/Pi\ Videos

Works flawlessly. Now, when I put this command in crontab to run every 15 minutes, it does not work and I am wondering if my command in crontab is correct?

*/15 * * * * rsync -avzhe ssh pi@192.168.1.45:/media/PNY/video /home/john/Desktop/Pi\ Videos
3

2 Answers

Wow, What a dig! I found the answer on linuxquestions.org

CLI and crontab run on different environments. Crontab needs to be told where the private key is. I followed the instructions on the link and simply added the location of private key on the command and it worked. The previous command now has this addition added.

*/15 * * * * rsync -avzhe "ssh -i /home/john/.ssh/id_rsa_dvr.pi" pi@192.168.1.45:/media/PNY/video /home/john/Desktop/Pi\ Videos

Now on to find a doctor that can help get some of these roots put back in. :-)

1

I suppose without parameters there is no need to use "-e" and "ssh" option in the scheduled command. Please try it plain:

*/15 * * * * rsync -avzh pi@192.168.1.45:/media/PNY/video /home/john /Desktop/Pi\ Videos
4

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like