Bash script parallel tasks and command to wait untill complete?

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Bash script parallel tasks and command to wait untill complete?
# 1  
Old 03-28-2014
Bash script parallel tasks and command to wait untill complete?


im having bash script with

while ***
command1 &&
command2 &&
command3 &&

i want to ask how i can prevent overloading server, by waiting untill all commands complete? any low resources intensive command like "wait" - i dont know if exist?
# 2  
Old 03-28-2014
From the man page:
wait [n ...]
Wait for each specified process and return its termination status. Each n may be a process ID or a job specification; if a job spec is given, all processes in that job's pipeline are waited for. If n is not given, all currently active child processes are waited for, and the return status is zero. If n specifies a non-existent process or job, the return status is 127. Otherwise, the return status is the exit status of the last process or job waited for.
# 3  
Old 03-28-2014
If you want to wait for all the 3 processes and also check their end status
command1 &
command2 &
command3 &

wait ${C1_PID}
wait ${C2_PID}
wait ${C3_PID}

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

(bash) Script Processes in Parallel

Hello all, I tried to parralise my treatments but after a while 'ps -ef' display all child process <defunct> (zombie) Parent bash script to process all files (>100000) in directory: for filename in /Data/*.txt; do ./ $filename & done exit(0)I understand that the... (1 Reply)
Discussion started by: namnetes
1 Replies

2. Shell Programming and Scripting

In Shell Script Does Second Command Wait For First Command To Complete

Hi All, I have a question related to Shell scripting. In my shell script, I have following two commands in sequence: sed 's/^/grep "^120" /g' $ORIGCHARGEDAMTLIST|sed "s;$;| cut -f$FIELD_NO1 -d '|' | awk '{ sum+=\$1} END {printf (\"%0.2f\\\n\", sum/100)}' >$TEMPFILE mv $TEMPFILE $ORIGFILE... (3 Replies)
Discussion started by: angshuman
3 Replies

3. Shell Programming and Scripting

Wait for one processes to complete in a shell script

Let's say I start process, then start process I call both of them in my How can I make sure that B starts its execution only after finishes. I have to do this in loop.Execution time of may vary everytime. It is a parameterized script. (17 Replies)
Discussion started by: rafa_fed2
17 Replies

4. Shell Programming and Scripting

Line in bash script to wait for x feedbacks and then continue

I have a script that runs a console/terminal command on the server and what is want is for each of the multiple success reports fed back from the clients (echo-ed out onto the conosle) to be counted and after x number of reports reboot the server. The Details: The command (program) is... (0 Replies)
Discussion started by: dp123
0 Replies

5. UNIX for Dummies Questions & Answers

How do you wait for command substitution processes to complete?

When running a command using the >(cmd) syntax in bash how do you wait for the command to complete before moving on in your script? Here is a simple example: zcat largefile.gz | tee >(wc && echo “HELLO”) > /dev/null # I tried wait, here but it doesn't wait for the process in the subshell.... (8 Replies)
Discussion started by: mrvwman
8 Replies

6. Filesystems, Disks and Memory

hdparm + HDIO_DRIVE_CMD(null) (wait for flush complete) failed: Inappropriate ioctl

Hi All, Am finding performance of my SD card using hdparm. hdparm -tT /dev/BlockDev0 /dev/BlockDev0: Timing cached reads: 1118 MB in 2.00 seconds = 558.61 MB/sec HDIO_DRIVE_CMD(null) (wait for flush complete) failed: Inappropriate ioctl for device Timing buffered disk reads: 14... (0 Replies)
Discussion started by: amio
0 Replies

7. UNIX for Dummies Questions & Answers

BASH complete-filename & menu-complete together

Hi, Does anyone know how to make BASH provide a list of possible completions on the first tab, and then start cycling through the possibilites on the next tab? Right now this is what I have in my .bashrc: bind "set show-all-if-ambiguous on" bind \\C-o:menu-complete This allows... (0 Replies)
Discussion started by: Mithu
0 Replies

8. Shell Programming and Scripting

Wait for Background Process to complete

I am attempting within a for-loop, to have my shell script (Solaris v8 ksh) wait until a copy file command to complete before continueing. The specific code is: for files in $(<inputfile.lst) do mv directory/$files directory/$files ksh -m -i bg %% wait $! done I am shaky on the... (3 Replies)
Discussion started by: gozer13
3 Replies

9. Shell Programming and Scripting

PERL: wait for process to complete

I'm using PERL on windows NT to try to run an extract of data. I have multiple zip files in multiple locations. I am extracting "*.t" from zip files and subsequently adding that file to one zip file so when the script is complete I should have one zip file with a whole bunch of ".t" files in it. ... (2 Replies)
Discussion started by: dangral
2 Replies
Login or Register to Ask a Question