4

I put this question on stackoverflow, because I found lots of quesions on the topic here already.

Short introduction

Simply put, nohup can be used to run apps in the background and keeps them running after the user logs off or the terminal or ssh session is closed e.g.

There are many example quesitons here on stackoverflow, like this or that.

My question is simple.

Why opt for nohup, when there are options like upstart, systemd, ... which manage the app as service in a much more convenient way (runlevels, ...)?

Reading the many questions on similar topics, the only option seems to be nohup. Almost never the answer is something like: "... use an upstart script, so it is all handled for you..."


I would mainly go with e.g. upstart, except maybe for a quick and dirty test scenario.

Am I missing something important?

rocksteady
  • 2,320
  • 5
  • 24
  • 40
  • Stack Overflow is a site for programming and development questions. This question appears to be off-topic because it is not about programming or development. See [What topics can I ask about here](http://stackoverflow.com/help/on-topic) in the Help Center. Perhaps [Super User](http://superuser.com/) or [Unix & Linux Stack Exchange](http://unix.stackexchange.com/) would be a better place to ask. Also see [Where do I post questions about Dev Ops?](http://meta.stackexchange.com/q/134306) – jww Feb 19 '17 at 17:36
  • I mentioned my intentions, but you are right, of course.. I'll look into that and move it, if possible. Thanks. – rocksteady Feb 19 '17 at 18:19

2 Answers2

10

nohup is quick, easy, doesn't require root access and doesn't make permanent changes in the system. That's why many people use it (or try to use it) instead of configuring services.

Running things in the background without any supervision is usually a bad idea, although there are many legitimate use cases which don't fit traditional service model. For example:

  1. Background process might be needed only sometimes, after certain user actions.
  2. More than one instance might be needed. For example: one per user or one per session.
  3. Process might not need to to be running all the time. It just quits after doing its job.

Some real world examples (which use something like nohup and would be hard to implement as system services):

  1. git will sometimes run git gc in background to optimize repository without blocking user work
  2. adb will start its service in background and keep it running until user asks to terminate it
  3. Some compilers have option to keep running in the background to reduce startup times of subsequent invocations
Piotr Praszmo
  • 17,928
  • 1
  • 57
  • 65
1

Your understanding is correct, the way those questions were asked the natural answer is nohup - upstart would be the answer to a different question such as How to make sure an application keeps running on Linux

Community
  • 1
  • 1
Julian
  • 2,837
  • 17
  • 15