2

I am running linux and I am running a script/program in the background using

cmd &

This works fine on Solaris, but on my Linux box (2.6.9-55/ Red Hat), the background process stops when the originating terminal window is closed/loses connection. What do I need to change this, so that this works as it works on Solaris?

2 Answers 2

6

You have to use the disown command (it may be specific to bash, not sure about it).

Example:

cmd & disown 

should do the trick.

If you want to reattach later the job to the terminal, use:

disown -h 

Alternatively, you can use screen. Use it this way:

screen cmd 

Then, to go back to the terminal, hit ctrl+a, then d.

To come back to the screen, type in any terminal:

screen -r 
1
  • I think you're wrong about reattachment with disown. Can you prove this performance? Commented Mar 4, 2010 at 14:44
7

if you run nohup cmd &, so the program will ignore the SIGHUP it gets when the termial closes.

1
  • This is definitely the solution that works for me. All disown seems to do is remove the process from the jobs list. Commented Sep 16, 2010 at 17:14

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.