Trying to create a bash script to run a command when rclone doesnt transfer anything x times

What is the problem you are having with rclone?

No issue on rclones side

What is your rclone version (output from rclone version)

rclone v1.51.0

Which OS you are using and how many bits (eg Windows 7, 64 bit)

Raspbian ARM64

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

local

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

rclone move

for the most part

The rclone config contents with secrets removed.

n/a

A log from the command with the -vv flag

n/a

Again. I want to make a bash script to run a command after my rclone command is ran and doesnt transfer any times X amount of times and until rclone transfers, the iteration resets to 0.

In psudocode, my goal is this:

int x = 0
rclone move (yada yada)

if rclone doesnt move any files{
x++
}

if x = 3{
x=0
my command is ran
}

ill tweak the code more since some logic is missing, but is there a way to keep count of when rclone transfers files?

if i understand what you want, perhaps you can use exit codes

https://rclone.org/docs/#list-of-exit-codes
9 - Operation successful, but no files transferred

How would i get the exit code to be considered a variable in the code? so like:

if exit code == 9{
x++
}

i am not a linux expert, you can search the net for
"linux error code from program"

#!/bin/bash

rclone copy source dest

if [ $? -eq 0 ]
then
  echo "rclone completed without error"
else
  echo "rclone completed with error" >&2
fi
1 Like

Got it! This looks promising to what I am trying to tackle. Thanks!

sure, glad to help.

perhaps at some point you can share your script.

If it works the way i want, Ill make an edit on this post :smile:

i did a little research, you might need this flag

https://rclone.org/docs/#error-on-no-transfer

yup! Im the same person with the other issue you just solved!

wow, i did not realize that until just now :upside_down_face:
thanks

no worries! Just finding out problems as i go. working on syntax now cx

no worries! Just finding out solutions as i go :upside_down_face:

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