I'm trying to run the script below recursively but it is generating multiple and simultaneous processes. how do I do to start same script again (last line of my script) only after he had just run entirely?
The file name is bachup.sh
I am using this command:
# / bin / bash /
rsync-avzu - delete-excluded / home / user / mnt / backup /
wait
sh / etc / backup.sh
bash has the interesting exec command which allows you replace the current shell with the command, this sends a HUP to all processes running in the shell
ie
So the first exec replaces the current process (read: your shell script) and no further code from it will be executed. Just start them without it, and it should work as expected.
First, please start using [CODE] tags when posting code, etc...
Second, as I said before, and DGPickett said here, leave out the exec. It replaces the current script with the one you're calling, and it won't run any part of the original script from there on. Nothing. Nada. And as long as you don't put any script into the background the shell will dutifully wait for it to finish before starting the next one.
For example by reading, not just skimming, what was written before. Or do you want a ready-to-go, complete, pre-chewed solution that only requires a minimum of cognitive abiliy?