Logo 
Search:

Unix / Linux / Ubuntu Forum

Ask Question   UnAnswered
Home » Forum » Unix / Linux / Ubuntu       RSS Feeds

Running independent script entries concurrently

  Date: Jan 21    Category: Unix / Linux / Ubuntu    Views: 408
  

I have the following shell script. It is setup to do 4 things. Unfortunately it
will not do the second task until the first has completed, the third until the
second has completed, you see where this is going ...

I would like for it to do all of these tasks and not wait until the previous has
terminated. Can this be done? How?

#!/bin/sh

# cd to pythonfc and run gedit
cd ~/pythonfc
gedit

# cd to pthonfc and run gnome-terminal
cd ~/pythonfc
gnome-terminal --geometry 207x30

# run evince and open 2011-03 Python Part 1 - issuePY01_en.pdf
evince "/home/mike/pythonfc/2011-03 Python Part 1 - issuePY01_en.pdf"

# run gedit and open all sh scripts for editing
gedit gedit.sh terminal.sh evince.sh gedit-terminal.sh

Share: 

 

2 Answers Found

 
Answer #1    Answered On: Jan 21    

Quote 'The Bash & (ampersand) is a builtin control operator used to
fork processes. From the Bash man page, "/If a command is terminated by
the control operator &, the shell executes the command in the background
in a subshell/".'

So the first part of your script becomes

#!/bin/sh

# cd to pythonfc and run gedit
cd ~/pythonfc
gedit &

However, I'm not certain whether or not the processes end when the
script ends, so you might want to leave the & off the final gedit.

 
Answer #2    Answered On: Jan 21    

Update - a quick test shows that the called processes do not end when
the script does, so you can put the & on the final gedit or not, as you
wish.

 
Didn't find what you were looking for? Find more on Running independent script entries concurrently Or get search suggestion and latest updates.