linux - How to run a background shell script which itself lauches two background processes? -


to start with, beginner programming etc apologies lack of professionally accurate terminology in question manage points across!

would have suggestions how in bash or tcsh can run long background process launches few programs , has run 3 long processes in parallel on different cores , wait 3 completed before proceeding...?

i have written shell script (for bash) apply image filter each frame of short heavy video clip (it's scientific tomogram not matter). supposed to:

  1. create file script convert whole file different format using em2em piece of software.

  2. split converted file 3 equal parts , filter each set of frames in separate process on separate cores on linux server (to speed things up) using program spider. firstly, 3 batch-mode files (filter_1/2/3.spi) required filtration parameters created , 3 subprocesses launched:

    spider spi/spd @filter_1 &  # first process launched main script , run in background on 1 core spider spi/spd @filter_2 &  # second background process run on next core spider spi/spd @filter_3    # third process run in parallel 2 above , finished before proceeding further. 

    these filtered fragments put @ end.

because wanted 3 filtration steps run simultaneously, sent first 2 background simple & , kept last 1 in foreground, main script process wait 3 finish (should happen @ same time) before proceeding further reassemble 3 chunks. works fine when run script in foreground throws lot of output info many subprocesses onto terminal. can reduce with:

$ ./my_script 2>&1 > /dev/null 

but each spider process still returns

*****spider normal stop***** 

to terminal. when try send main process background keeps stopping time.

would have suggestions how can run main script in background , still run 3 spider sub-processes in parallel somehow?

thanks!

you can launch each spider in background, storing process ids can later use in wait command, such as:

spider spi/spd @filter_1 & sp1=$! spider spi/spd @filter_2 & sp2=$! spider spi/spd @filter_3 & sp3=$! wait $sp1 $sp2 $sp3 

if want rid of output, apply redirections on each command.

update: don't need store pids, wait without parameters automatically wait spawned children.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -