1

And if so, can it be kept alive somehow?

(This is not a duplicate question since I did not know that logging out will kill a process. Maybe others also don't and so ask the wrong question.

I would suggest that the answers include a link to the other question.)

bomben
  • 2,167

2 Answers2

3

Yes, the process will get a "Hangup" signal (SIGHUP), which is not usually caught, and results in process termination. Read man -a signal and the man pages it points to.

The nohup command was designed to overcome this difficulty, without the overhead of screen or tmux (nohup was invented first, back when "Hangup" referred to modems). You can specify a logfile, or let nohup save STDOUT and STDERR to ./nohup.out, if possible, or $HOME/nohup.out if not.

nohup command >$HOME/command.log &
waltinator
  • 37,856
1

Yes, commands you have started will be stopped if you log out. But you can start them using the screen command:

$ screen command

From this virtual screen you can exit afterwards (Ctrl+A, D), while letting the command proceed running.

You can start a command and instantly send it into a virtual detached screen as well:

$ screen -fa -d -m command

To get an overview of your screen sessions, use the following command:

$ screen -list
There are screens on:
    2457.pts-2.myserver (22.10.2018 20:04:35)   (Detached)
    12596.pts-3.myserver    (28.08.2018 22:10:00)   (Detached)
    4632..myserver  (15.07.2018 20:56:55)   (Detached)
3 Sockets in /run/screen/S-me.
$ 

Bring a session back in foreground, using the -r switch, while giving the session id:

$ screen -r 2457.pts-2.myserver
Nicolas
  • 865