Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

running 2 command in same time 1

Status
Not open for further replies.

paijo

Technical User
Apr 13, 2005
4
NG
hi all,
I want to run my 3 scripts in one scripts, but the problem they will run in sequence of each line, it will run the 2 scripts after the first already finish runing and so is the 3rd script will be run after the 2nd finishing ?
is there any tips how to run all scripts not in sequence but I can run all in one single time only using one main scripts ?

for example.
mainscripts.
/etc/home/scripts1
/etc/home/scripts2
/etc/home/scripts3

I need run scripts1, scripts2 and scripts3 in one single time , not in sequence.


thanks a lot

paijo

 
Run the first two in background. Redirect stdout and stderr if required.

mainscripts.
/etc/home/scripts1 >script1.out 2>&1&
/etc/home/scripts2 >script2.out 2>&1&
/etc/home/scripts3
 
One more thing on the above:
If script3 finishes before script1 and script2, the first two may terminate early. This would happen if the user who calls "mainscripts" logs out.

If that is the case, start the first two scripts with the "nohup" command like this:

mainscripts.
/bin/nohup /etc/home/scripts1 >script1.out 2>&1&
/bin/nohup /etc/home/scripts2 >script2.out 2>&1&
/etc/home/scripts3
 
Another way to allow completion of the 3 scripts:
/etc/home/scripts1 >script1.out 2>&1 &
/etc/home/scripts2 >script2.out 2>&1 &
/etc/home/scripts3
wait

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
thanks to all of you guys.
it works perfectly....
now I can do my other scripts.


thanks again


paijo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top