Rclone: Unable to run from Cron

Created on 5 Jul 2016  路  2Comments  路  Source: rclone/rclone

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.

Most helpful comment

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.

  1. Use the full path to rclone in your script
    OR
  2. Modify the PATH in the cron job

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

All 2 comments

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.

  1. Use the full path to rclone in your script
    OR
  2. Modify the PATH in the cron job

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

acuteaura picture acuteaura  路  3Comments

suityou01 picture suityou01  路  3Comments

Randomico picture Randomico  路  3Comments

klierik picture klierik  路  3Comments

dandv picture dandv  路  3Comments