So I have this rsync script I wrote to grab some sql files and import them to a database. I left in the mysql stuff just give context to the situation. The real problem is with my rsync code.
script.sh (chmod 744)
#!/bin/sh
rsync -av --rsh="sshpass -p'PASSWORD' ssh -l'USERNAME'" WEBSITE.com:/PATH/TO/RSYNC/REMOTE /PATH/TO/RSYNC/LOCAL
tables=(TABLE1 TABLE2)
for name in ${tables[@]}
do
mysql -u'USER' -p'PASSWORD' DBNAME < PATH/TO/SQLFILES/$name.sql
done
My cron looks like this ...
0 * * * * /PATH/TO/SCRIPT/script.sh
Here's the problem. When I execute the script in bash, it works fine. But my cron job returns these errors
rsync: Failed to exec sshpass: No such file or directory (2)
rsync error: error in IPC code (code 14) at pipe.c(84) [receiver=3.0.6]
rsync: connection unexpectedly closed (0 bytes received so far) [receiver]
rsync error: error in rsync protocol data stream (code 12) at io.c(600) [receiver=3.0.6]
I don't get it, why would the script work in bash but not in cron ? What am I doing wrong ? :wall:
Thanks