LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-18-2006, 08:38 AM   #1
beeblequix
Member
 
Registered: Oct 2005
Location: Tierra Firma, Earth
Distribution: Debian of course...
Posts: 196

Rep: Reputation: 30
how to launch two shell scripts at once


I want to launch two shell scripts at once. The first is a korn shell script, the second a bash script. Originally I considered adding the bash script as a line in the korn script but then it occurred to me that the korn script would wait until the bash script is done before moving on to the next line. The idea is that I want the bash script to take snapshots of what's happening during the first 90 seconds of the korn script.

Would this work?:
me@mysles8server> ./mykornscript & ; ./mybashscript

If I read that right it runs the korn script in bg and the bash script in foreground.

Maybe I wouldn't have to use the '&' symbol and just type them both separated by the semicolon --
./mykornscript;./mybashscript

Maybe I can drop that line separated by a semicolon into a script of its own to keep things easy. Hmmm......I'll test this in a few hours when I get to work and report for any other n00bs like me who may find it useful.

Last edited by beeblequix; 10-18-2006 at 08:40 AM.
 
Old 10-18-2006, 09:00 AM   #2
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
Separating commands with a semi-colon is just like pressing return, so this:
Code:
command1 ; command2
...would run command1, wait for it to finish and then run command2, wait for that to finish and then give you your prompt back.

If you want to run command1 and command2 in parallel, you can do it with the &, but you don't need the semi-colon:
Code:
command1 & command2
Which will run command1 in the background, run command2 in the foreground, and give you the prompt back when command2 is complete. note that command1 may terminate before command2, but you'll not get the notification until command2 is complete. It could also keep running after you get the prompt back. To check the status of backgrounded jobs, you can type jobs

You could put them both in the background like this:
Code:
command1 & command2 &
...which will put them both in the background and give you the prompt back straight away. There is a special command called wait which waits until all background processes are complete, and then gives you the prompt back. So this command:

Code:
command1 & command2 & wait
Will launch command1 and command2, and wait until both are complete.

Enjoy
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Launch CGI script from shell alex986best Linux - Newbie 2 06-28-2006 07:28 AM
shell script launch two apps webreake Programming 4 04-01-2006 08:29 PM
help on shell script as a wrapper to launch default programs according to input file daveiro Programming 2 11-24-2005 05:20 PM
Unable to launch X apps with non login root shell kc00l Slackware 2 11-24-2003 04:32 AM
can't launch java app from shell script... LonAllen Linux - Newbie 0 07-07-2003 09:37 AM


All times are GMT -5. The time now is 12:47 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration