Rclone in cron job

i am using rclone on my qnap nas to create backup to google, i made a shell script that looks like this

#!/bin/bash
if pidof -o %PPID -x "uploadfilms.sh"; then
exit 1
fi

rclone copy /share/Film gcrypt:Film --progress --fast-list --checkers 10 --transfers=10 --tpslimit=3 --log-file=/share/Tom/rclone.txt -v

exit

when i run this script in putty terminal on my nas it works perfect,

but whenever i want it to run as a cronjob it throws me this error

2022/09/13 17:17:01 INFO : Starting transaction limiter: max 3 transactions/s with burst 1
2022/09/13 17:17:12 Failed to create file system for "gcrypt:Film": failed to make remote "gdrive:Private" to wrap: couldn't find root directory ID: Get "https://www.googleapis.com/drive/v3/files/root?alt=json&fields=id&prettyPrint=false&supportsAllDrives=true": couldn't fetch token - maybe it has expired? - refresh with "rclone config reconnect gdrive:": oauth2: cannot fetch token: 401 Unauthorized
Response: {
"error": "deleted_client",
"error_description": "The OAuth client was deleted."
}


rclone config file

[gdrive]
type = drive
client_id = xxxxx.apps.googleusercontent.com
client_secret =xxx
scope = drive
token = {"access_token":"xxx"}
team_drive =

id and secret has been redacted

[gcrypt]
type = crypt
remote = gdrive:Private
password =xxx

password has been redacted

Run that to reconnect the remote.

i tried that, it says succes on the webpage All done. Please go back to rclone.
but when it runs as a cronjob it throws me the same error, and as i said, when i run the command manually via putty on my nas it works fine,

Are they running as the same user?

Would be helpful to share the full log, rclone version output, basically the stuff in the help/support template.

you know what, with the extra -v you know the -vv i found out when i run it as a cronjob it uses an old rclone config file
so now it works, i dont know why it would use a config file from another location, but anyway it works now sorry for the trouble

The rclone.config file is per user so if you are running it as the same user, it should be ok, but most folks pass a config flag to use a specific location.

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