LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   How can i run two bash scripts at same time? (https://www.linuxquestions.org/questions/programming-9/how-can-i-run-two-bash-scripts-at-same-time-480422/)

helptonewbie 09-04-2006 06:34 PM

How can i run two bash scripts at same time?
 
Hello,
I would like to know how i can run two or three bash scripts at the same time all of them being called from another script. Currently i use
/file1 | /file2 | /file3
but there must be a better way as what i really want is to do something like this

# "lots of commands in the script file"
# then use a command to run file
/file1 # whilst this is executing, carry on with the
# rest of the scripts in this current file instead of having
# to wait for completion of the newly executed file
echo "blah blah"
if [ la la la ]; then
ta ta ta
fi

Thanks very Much for any ideas

spirit receiver 09-04-2006 06:49 PM

Append "&" to the command, as in
Code:

(sleep 2; echo "slept two seconds") & echo "second command"
This will launch a background process for the command, which is also a very common thing to do from the console, as the shell will immediately be available again without being blocked by the running program.

Maybe you should have a look at some Bash introduction like this one.

jerp 09-05-2006 05:00 PM

I use exec and save the PID to a variable. That way I can manipulate the process if necessary, or check to see if it's still running.

helptonewbie 09-05-2006 06:25 PM

Hello, Thanks for repling.
I have managed to get a good kind of result by doing this:-
(thanks spirit, i used that site sugested)
/filepath/file1 &

that runs the command in the background as a seperate thing, however Jerp, i'd be interested to hear more about your idea. Could you show me a script or example of your method please

Thanks Again all


All times are GMT -5. The time now is 04:11 PM.