Problem when copying a file to GDRIVE with bash script on server linux

What is the problem you are having with rclone?

hello if i execute the following command from the command line:
rclone copy /mydir/file.jpg gdrive:TEST
the command is executed perfectly and in the TEST directory of GoogleDrive I find the saved image.

If I run the same command line in a bash script script.sh I get this error:

2024/12/30 19:34:52 ERROR : Attempt 1/3 failed with 1 errors and: couldn't list directory: Get ‘https://www.googleapis.com/drive/v3/files?alt=json&fields=files(id%2Cname.........shortcut')&supportsAllDrives=true": couldn't fetch token: invalid_grant: maybe token expired? - try refreshing with "rclone config reconnect gdrive:"

Run the command 'rclone version' and share the full output of the command.

Which cloud storage system are you using? (eg Google Drive)

Google Drive

The command you were trying to run (eg rclone copy /tmp remote:tmp)

Paste command here

Please run 'rclone config redacted' and share the full output. If you get command not found, please make sure to update rclone.

[gdrive]
type = drive
client_id = XXX
client_secret = XXX
scope = drive
token = XXX
team_drive = 
### Double check the config for sensitive info before posting publicly

welcome to the forum,

please, can you post the full output of rclone version ?

run the command with debug output, for example
add -vv --retries=1 or --log-level=DEBUG --log-file=~/rclone.log --retries=1

then, post the output.

rclone v1.68.2

  • os/version: raspbian 10.13
  • os/kernel: 5.10.103-v7+ (armv7l)
  • os/type: linux
  • os/arch: arm (ARMv7 compatible)
  • go/version: go1.23.3
  • go/linking: static
  • go/tags: none

How exactly your shell script looks like? How do you run it? Using the same user as you command line?

There is no magic - if results are different it means then this is not the same command (in broad terms) run. Can be permissions, environment etc.

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