Nohup vs. Screen

gnu-screennohupprocess

In the past, I've used nohup to run big background jobs, but I've noticed that a lot of people use screen in this context. Does screen provide some kind of functional advantage that I am unaware of, or is it just a matter of preference?

Best Answer

Both have their own plusses and minuses:

nohup:

  1. nohup is good to use for running processes in the background when the processes don't need any user input, like a web server or any other server process like that.
  2. nohup does create log in the directory of process execution.  The log file name is nohup.out .
  3. It avoids the process getting killed due to mistaken Ctrl+C or similar key combination.  Just a safeguard.
  4. It's normally installed by default with basic setup. No need to install separately like screen.
  5. Its functionality is very specific to running a job in background and dumping output. Low memory intensive.

screen:

  1. Got to install separately. You cannot go to a data center or login to any box and expect screen is present.
  2. Good to manage multiple terminals on separate subjects and give them names.
  3. Its more of terminal manager and not a command to run a process for infinite time like nohup.
  4. It's more suitable if the process needs user input. Like install scripts, yes/no prompts.
  5. With tons of features, comes its memory. But agreed, some are really great features.

@rahmu, I will never guess pid if want to kill it. Be sure before killing someone/something ;) .

Best way in both cases for screen and nohup is: ps -eaf | grep "nohup" | grep "your proc name/keyword".

Use screen and check what is running on it.

To conclude, they are two different things made with different agendas, so comparison is difficult.