Wait function in a script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Wait function in a script
# 1  
Old 09-14-2010
Wait function in a script

Hi everyone,

I need some help to create a script. This script have to create a file once all the process inside are finish.

Here how I want to do :
Code:
#!/bin/ksh

/home/oracle/save1.ksh &
proc_id1=$!

/home/oracle/save2.ksh &
proc_id2=$!

/home/oracle/save3.ksh &
proc_id3=$!

/home/oracle/save4.ksh &
proc_id4=$!

wait proc_id1 proc_id2 proc_id3 proc_id4

> /save/ok.svg

Can you tell me if it's the good way.


Thank you for your help and sorry for my english.
# 2  
Old 09-14-2010
You do not to specify all the process IDs. wait by itself will wait for all the currently active child processes.
# 3  
Old 09-14-2010
for example:
Code:
#!/bin/ksh

/home/oracle/save1.ksh &
proc_id1=$!

/home/oracle/save2.ksh &
proc_id2=$!

/home/oracle/save3.ksh &
proc_id3=$!

/home/oracle/save4.ksh &
proc_id4=$!

wait 
> /save/ok.svg

# 4  
Old 09-15-2010
Ok thank you for your help, I will try this
# 5  
Old 09-16-2010
Thank you for youur help it's work great !
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Script to run another script with wait time

I want to create a script which calls another script with certain interval. Script "A" should call script "B" every 60 seconds. Script "A" should also be able to call other scripts such as "C", "D", etc. at an interval of 60, 120, 180 seconds respectively. Basically script A should take two... (1 Reply)
Discussion started by: Vee
1 Replies

2. Shell Programming and Scripting

Script using Wait

Hi, written a script which uses wait as follows Main.sh #!/usr/bin/ksh nohup scrpit1 1 & pid_1=$! nohup scrpit1 2 & pid_2=$! wait $pid_1 wait $pid_2 nohup scrpit1 3 & pid_1=$! nohup scrpit1 4 & (1 Reply)
Discussion started by: krux_rap
1 Replies

3. Shell Programming and Scripting

Script should wait for password while doing scp

Hi team, need help on this :- trying to scp a file from A ( it could any server among hundreds not one) server to B server ( fixed ) . The script runs in a third server CFGEngine server. a. we dont use static password ( its pin + rsa token) so , "here documents" kind of thing is not... (3 Replies)
Discussion started by: gauravsharma29
3 Replies

4. Shell Programming and Scripting

calling a shell script in background and wait using "wait" in while loop

Hi, I am facing a strange issue, when i call a script from my while loop in background it doesnt go in background, despite the wait i put below the whil loop it goes forward even before the process put in background is completed. cat abc.txt | while read -u4 line do #if line contains #... (2 Replies)
Discussion started by: mihirvora16
2 Replies

5. UNIX for Dummies Questions & Answers

wait() function...

when wait() is called by process it blocks calling process until child is done. What happens if calling process have multiple children. What does wait(NULL) function do. Waits until all children are done? (1 Reply)
Discussion started by: joker40
1 Replies

6. Shell Programming and Scripting

race condition with wait() function

Hi, I'm currently writing a bash script, that starts multiple threads: ____________________ #!/bin/bash loop=0 while((loop!=10)) do thread & ((loop++)) done #wait for all sub-processes (thread) to finish wait ___________________ Now I want to know, what happens, if a... (2 Replies)
Discussion started by: tho99
2 Replies

7. Shell Programming and Scripting

To force a script to wait for another.

Hi All! Here is the problem, I'm trying to develop a script that can help me with the raid creation, but, till now, I have been dealing for more than a week and I still didn't achieve any satisfactory results. :confused: Here is the code to execute: # mdadm --manage /dev/md0 --add... (4 Replies)
Discussion started by: Ne7o7
4 Replies

8. Shell Programming and Scripting

wait command - cat it wait for not-chile process?

Did not use 'wait' yet. How I understand by now the wait works only for child processes, started background. Is there any other way to watch completion of any, not related process (at least, a process, owned by the same user?) I need to start a background process, witch will be waiting... (2 Replies)
Discussion started by: alex_5161
2 Replies

9. Shell Programming and Scripting

wait for 5 seconds in shell script

hi how can i wait for 5 seconds inside my shell script? 'wait 5' command doesnot seem to be working? (2 Replies)
Discussion started by: gopsman
2 Replies

10. Shell Programming and Scripting

make my script wait

is there a way to make my script wait before doing something without using the "sleep _" command? (4 Replies)
Discussion started by: Blip
4 Replies
Login or Register to Ask a Question