Linux - background process

I want to run the process on a remote Linux server and save this process after closing the putty terminal,

what is the right team?

+4
source share
3 answers

You have two options:

  • Use the GNU screen , which allows you to run a command and disconnect it from your terminal, and then reconnect it to another session. I use it for lengthy processes, the output of which I want to track at any time. The screen is a really powerful tool, and I highly recommend taking some time to learn it.
  • Run the command as nohup some-command & , which will run the command in the background, disconnect it from the console, and redirect its output to nohup.out . It will swallow the SIGHUP that are sent to the process. (When you close the terminal or log out, SIGHUP is sent to all processes that have been started by the login shell, and the default action that will be performed by the kernel is to kill the process. Therefore, adding & to set the process in the background is not enough to he withstood the exit.)
+6
source

do not use this nohup garbage, I hate to see it on servers; the screen is an empty bunch of bits and the use of rotting - use tmux.

if you want to create a background process, a double fork, like any other daemon from the very beginning:

 # ((exec sleep 30)&) # grep PPid /proc/`pgrep sleep`/status PPid: 1 # jobs # disown bash: disown: current: no such job 

to use.

+1
source

A command running in parentheses

 (command &) 

will survive after the death of the original shell.

+1
source

Source: https://habr.com/ru/post/1333274/


All Articles