I am trying to run my rclone command on my Ubuntu Servers in a cron job. Running the job directly from the command line runs fine, however from a cron job I get the error /bin/sh: 1: rclone: not found. I am trying running the command /home/backup googlecloud:accessdrive_net/Main -v > /var/log/rclone.log 2>&1 to sync with Google Cloud Storage.
It's most likely that rclone isn't in the PATH set by cron. I'm assuming /home/backup is a script in the following suggestions.
To determine the actual location of rclone, run which rclone. It depends on your system, but you'll get something like /usr/local/bin/rclone.
To do (1), replace every invocation of rclone in your script with the full path you got from which rclone. To do (2), add the following line to the top of the crontab (I assume rclone is at the path given in my example).
PATH="/usr/local/bin:$PATH"
Such that your crontab looks something like this, if I'm making the right assumptions.
PATH="/usr/local/bin:$PATH"
0 0 * * * /home/backup googlecloud:accessdrive_net/Main -v > /var/log/rclone.log 2>&1
I made a mistake when referring to the command that I was running, which was actually rclone sync /home/backup googlecloud:accessdrive_net/Main -v > /var/log/rclone.log 2>&1. I was able to use which rclone to find the actual location and call that path in the cron job so I am able to run it now. Thanks.
Most helpful comment
It's most likely that rclone isn't in the PATH set by cron. I'm assuming
/home/backupis a script in the following suggestions.OR
To determine the actual location of rclone, run
which rclone. It depends on your system, but you'll get something like/usr/local/bin/rclone.To do (1), replace every invocation of rclone in your script with the full path you got from
which rclone. To do (2), add the following line to the top of the crontab (I assume rclone is at the path given in my example).Such that your crontab looks something like this, if I'm making the right assumptions.