Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I launch a program inside a shell script and have the shell script continue, even though the program remains open

Tags:

bash

shell

I am using bash on Ubuntu. I would like to have a shell script open a program and continue on to the next line of the shell script, even though the program has not terminated.

like image 623
Jake Avatar asked Aug 04 '11 21:08

Jake


2 Answers

Adding an & to a command places it in background.

example:

/path/to/foo    
/path/to/bar     # not executed untill foo is done


/path/to/foo &    # in background
/path/to/bar &    # executes as soon as foo is started

Read more about job-control here and here

like image 59
Fredrik Pihl Avatar answered Nov 15 '22 11:11

Fredrik Pihl


Use something like this (my-long-running-process &) . This will launch your script as a separate process in the background.

like image 27
arunkumar Avatar answered Nov 15 '22 10:11

arunkumar