how to run a script in back ground within a script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to run a script in back ground within a script
# 1  
Old 05-25-2012
how to run a script in back ground within a script

Hi friends,
i have two scripts(call it bg1.ksh and bg2.ksh) which needs to be run parallely on background from a script(call it test1.ksh).then i have to wait till these two back ground job gets finished. and once it is completed , then i have to trigger one more script(call it test2.ksh) within test1.ksh. could you please guide me how to do it?

note: i am working in korn shell(ksh88)

please help. thanks in advance.
# 2  
Old 05-25-2012
Code:
#!/bin/sh

./bg1.ksh & # One & on the end means 'run it in the background'.
./bg2.ksh &
wait # This will wait for both of them to finish.

./test2.ksh # This one gets run in the foreground.

This User Gave Thanks to Corona688 For This Post:
# 3  
Old 05-25-2012
@corona thanks for your reply. i have two more questions.1> for the above solution, does all four script needs to be in same folder??.. 2> will it work in korn shell?
# 4  
Old 05-25-2012
They are all in the same folder that way, but they don't have to be. You could as easily do relative/path/script.sh & or /absolute/path/to/script.sh &.

And yes, it will work in KSH. It will work in any Bourne-derived shell really, since it only uses basic Bourne features.
This User Gave Thanks to Corona688 For This Post:
# 5  
Old 05-25-2012
thanks lot Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Capture run time of python script executed inside shell script

I have bash shell script which is internally calling python script.I would like to know how long python is taking to execute.I am not allowed to do changes in python script.Please note i need to know execution time of python script which is getting executed inside shell .I need to store execution... (2 Replies)
Discussion started by: Adfire
2 Replies

2. Shell Programming and Scripting

Script to read a log file and run 2nd script if the dates match

# cat /tmp/checkdate.log SQL*Plus: Release 11.2.0.1.0 Production on Mon Sep 17 22:49:00 2012 Copyright (c) 1982, 2009, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production FIRST_TIME NEXT_TIME... (1 Reply)
Discussion started by: SarwalR
1 Replies

3. Shell Programming and Scripting

prevent multiple tail in back ground

Dears i have a scrip run in unix that need to use the tail -f command, as below: DATE=`date '+%m%d%y'` tail -f /var/messages | grep "start" >> /export/logs/start_${DATE}.out but the problem that the tail -f will be stop and working in the background in then end of the day (23:59:59)... (0 Replies)
Discussion started by: thehero
0 Replies

4. Shell Programming and Scripting

Doing a tail in a script and then return back and continue script

Hello all, I am trying to do a tail in a script. But when I quit the tail my script quits also. This is not what I want. I am struggling to get this done. #!/bin/bash askFile() { echo -n "Enter file: " read FILE } doTail() { tail -F "${1}" } askFile doTail... (4 Replies)
Discussion started by: markdark
4 Replies

5. AIX

Help with back ground scripts...

I have a user that runs a menu driven application, is there a way to see what scripts this application is executing in the back ground? OS=AIX 4.3 (1 Reply)
Discussion started by: mangolinux
1 Replies

6. Shell Programming and Scripting

Run script in back ground

I have a script "a" running in background. From script "a" i will kick off script "b" which will also be in background. Is this possible. And actually what i want is, In script "b" when i do ps -ef, script "a" should not be seen. Current "a" script ---- --- ---- nohup b exit current... (1 Reply)
Discussion started by: vasuarjula
1 Replies

7. UNIX for Dummies Questions & Answers

Executing scripts in back ground

Hi, Test1.ksh #! /bin/ksh for i in $* do #echo "$i" ksh test2.ksh $i & done test2.ksh #! /bin/ksh sleep 5s echo "From Test 1 ==> $1" exit 0; I am executing as follows: ksh test1.ksh a b c (10 Replies)
Discussion started by: risshanth
10 Replies
Login or Register to Ask a Question