0

I am running a bash script that performs rclone on a directory with multiple files. However, the bash command does not finish and I get a repeating warning instead. Below you will find my bash file


#!/bin/bash
echo "starting f2f perf tests"

source="/datadrive/0B-2500Files"

target="/mnt/perftest"

cd "${source}"

#ls /datadrive/Empty-Dir-Structure-250K | xargs -n1 -P4 -I% rsync -Pa % /datadrive/Empty-Dir-Structure-250K
rclone sync {source} {target} --transfers 256 --checkers 256 -v --log-file=/tmp/sync.log 

time /home/marcelomo/f2f-small-files-one-vm.sh
echo "rclone is done"

The error that is outputted is:

/bin/bash: warning: shell level (1000) too high, resetting to 1
/bin/bash: warning: shell level (1000) too high, resetting to 1
/bin/bash: warning: shell level (1000) too high, resetting to 1
/bin/bash: warning: shell level (1000) too high, resetting to 1
/bin/bash: warning: shell level (1000) too high, resetting to 1
/bin/bash: warning: shell level (1000) too high, resetting to 1
/bin/bash: warning: shell level (1000) too high, resetting to 1
... 

And this warning just repeats itself. Is my bash script calling itself? I confirm that the source and destination directories exist. In addition, I am able to move files with rsync but I get this repeated warning with rclone only.

What I eventually want to do is record the time it takes to rclone different file sizes, varying the number of parallel transfers with the --transfers argument by running a bash script.

Any advice would be much appreciated, thanks!

marcelomo
  • 3
  • 3
  • You seem to have forgotten the dollar signs on two variable expansions in the call to `rclone`. Are you calling the script itself recursively with `time` at the end of the script? – Kusalananda Jun 14 '22 at 21:32
  • @Kusalananda No, I am just calling time once at the end of the script to record how long it takes the script to finish running – marcelomo Jun 14 '22 at 21:34
  • The `time` keyword takes a utility and runs it. After running it, it displays the time it took. If you call the script itself with `time`, it would obviously endlessly recurse until it runs out of memory. It would make more sense to call the script with `time` from _outside_ the script. – Kusalananda Jun 14 '22 at 21:35
  • 1
    @Kusalananda thank you much! I understand what I did wrong and I fixed it – marcelomo Jun 14 '22 at 21:47

1 Answers1

1

The time keyword runs the given utility and reports the time it took to run it.

Since you call the script itself, from within the script, with time, running the script will involve calling time with the script, which in turn will call time with the script, etc., until you run out of memory.

In short, you have managed to create an infinitely recursive script.

To fix this, just remove the whole line calling time and just use time when invoking the script from the command line or cron schedule of from wherever you call the script.

Additionally, you have used {source} and {target} in the call to rclone. These should probably read "$source" and "$target" respectively.

Kusalananda
  • 320,670
  • 36
  • 633
  • 936