Where do I add nohup
and &
to put this in the background?
I tried multiple places and had no luck.
find . -links 2 -type d |
xargs -I{} -P 5 -n 1 bash -c 'cd "{}" && run_script.sh'
Simplest answer - just put it at the end of the line.
find . -links 2 -type d | xargs -I{} -P 5 -n 1 bash -c 'cd "{}" && run_script.sh' &
That effectively puts the pipeline in background.
You're probably going to want to manage your i/o though.
-P 5-n
should probably be -P 5 -n
. You can put the nohup
in front of the find
.
cd "{}" && nohup run_script.sh &'. That will thow a
nohup.out` in every directory, but your output (if any) will be clearly associated with the relevant location. You could manage your own redirections if you wanted. Make sure here is useful logging, even if it's just turning on debug mode with set -x
inside run_script.sh
.
Commented
Jul 22, 2021 at 15:30
bash -c 'cd "{}"...
will break on"
, Use arguments -xargs -n1 bash -c 'cd "$1"' --