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

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

Maya Lin-Takahashi

Maya Lin-Takahashi

Consumer Tech & Gadget Reviewer

Maya is a hardware enthusiast who tests and reviews smart home devices, smartphones, wearables, and audio gear. She focuses on practical consumer value and build quality.

Share this article
Twitter Facebook Pinterest