Rsync work on ssh but not on cron

Hello,
I have diifficulties, where I have ssh command as follows:
sshpass -p “myPassword” rsync --update --delete -vaz --progress /home/some_user/web/ root@some_ip_address:/home/someuser/web/

Rsync command above works on ssh. But not on cron.
And here is the error log:
sent 0 bytes received 0 bytes total size 0
rsync error: unexplained error (code 255) at rsync.c(713) [sender=3.2.7]

Can someone help me with this issue? Big thank’s in advance

First of all. That problem is not related to Hestia so…

Anyway, I don’t know what that error means but if you are using cron, always use the full path to commands, enclose the password in single quotes and just in case, add ssh option StrictHostKeyChecking=accept-new'. Also, if you are not running the command interactively, maybe the --progress option is not a good idea.

/usr/bin/sshpass -p 'myPassword' /usr/bin/rsync --update --delete -vaz -e 'ssh -o StrictHostKeyChecking=accept-new' /home/some_user/web/ root@some_ip_address:/home/someuser/web/

Allowing root user to login to a remote machine using a password is not a good idea, Also, it isn’t a good idea to write the root’s password directly in a cron job :stuck_out_tongue:

1 Like

Dear Sahsanu,
I tried your suggestion, and I just can’t believe IT WORKS.

For the other user who has problem like me, the main fix is to add this on the rsync command :

-e 'ssh -o StrictHostKeyChecking=accept-new'

Yes, I know it not a good idea to put a password on a cron job, but this is the only option for me this time.
After 2 week of struggles and headache, you are my life saver and thank you very much. GBU

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.