Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Possible Duplicate:
How do I fork a process that doesn't die when shell exits?

Sometimes I remotely connect to my Ubuntu using NX. I then run some jobs in the background, e.g.:

$ /path/to/script.pl &

However, when I log out, the jobs stop running.

How can I make them continue even after I log out?

share|improve this question

marked as duplicate by grawity, Majenko, Nifle, studiohack Apr 27 '11 at 19:04

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

add comment

4 Answers 4

up vote 2 down vote accepted

I think another alternative would be to use screen.

share|improve this answer
    
nohup is one option, but screen is a much better solution. +1. –  peelman Sep 21 '10 at 2:01
    
How should i run my script using screen? –  David B Sep 21 '10 at 9:56
add comment

The shell kills all processes in its process group when it ends, by sending SIGHUP.

If you run the bash shell, you can type disown to keep it running after you log out. This removes it from the list of processes it will send signals to.

Or you can launch the script with nohup, but then you have to remember this when you run the command. This tells your command to ignore the SIGHUP signal that the shell will send. This will work on any shell.

share|improve this answer
add comment

You can use nohup

nohup /path/to/script.pl &
share|improve this answer
add comment

See "Keep linux scripts running after you have closed a remote shell" for how to do this using the screen command.

The answer lies in a command line tool called screen.

Screen allows you to start a process on a virtual screen, then detach that screen and do >something else (including log out). You can also reattach your screen after logging out >and logging in again.

If you dont have the screen command on your remote linux box, first install it either from source or using your favourite package manager. Then login into your remote box and run your desired command prefixed with “screen”. For example:

screen top

Now to detach the screen use CTRL+a followed by d. This will detach your screen and you can go about any other business, including quitting your remote session.

Reattaching you screen at any time is as simple as running the command:

screen -r

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.