views:

249

answers:

3

I honestly can't believe I can't find a solution for this online. I've run across a few things that seem similar, but nothing that really does what I want...

I'm trying to use a shell script to start a command. I don't care if/when/how/why it finishes. I want the process to start and run, but I want to be able to get back to my shell immediately...

Hope thats clear enough, I'm probably just missing something incredibly stupid

+8  A: 

You can just run the script in the background:

$ myscript &

Note that this is different from putting the & inside your script, which probably won't do what you want.

Carl Norum
I knew it was going to be something easy, thanks a ton... Linux just isn't my thing, but I'm trying to get up to speed... Btw, will this work when combined with nohup?
LorenVS
@LorenVS, I think so.
Carl Norum
Score, thanks for the help Carl
LorenVS
+5  A: 

Alternatively, after you got the program running, you can hit Ctrl-Z which stops your program and then type

bg

which puts your last stopped program in the background. (Useful if your started something without '&' and still want it in the backgroung without restarting it)

pajton
Thanks, thats a cool little trick... Starting to really appreciate some of the shell goodness...
LorenVS
+2  A: 
nohup cmd

doesn't hangup when you close the terminal. output by default does to nohup.out

You can combine this with backgrounding,

nohup cmd &

and get rid of the output,

nohup cmd > /dev/null 2>&1 &

you can also disown a command. type cmd, Ctrl-Z, bg, disown

Steve B.
LorenVS