Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

linux - running process background

Tags:

linux

I want to run a process in a remote linux server and keep that process alive after close the putty terminal,

what is the correct command?

like image 309
Buddhi Avatar asked Dec 24 '10 08:12

Buddhi


1 Answers

You have two options:

  1. Use GNU screen, which will allow you to run the command and detach it from your terminal, and later re-attach it to a different session. I use it for long-running processes whose output I want to be able to monitor at any time. Screen is a truly powerful tool and I would highly recommend spending some time to learn it.
  2. Run the command as nohup some-command &, which will run the command in the background, detach it from the console, and redirect its output into nohup.out. It will swallow SIGHUPs that are sent to the process. (When you close the terminal or log out, SIGHUP is sent to all processes that were started by the login shell, and the default action the kernel will take is to kill the process off. This is why appending & to put the process in the background is not enough for it to survive a logout.)
like image 63
cdhowie Avatar answered Nov 09 '22 12:11

cdhowie