How do I keep jobs running after logout? [duplicate]
I think another alternative would be to use screen.
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.
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