-2

There are quite a lot precautions one is to take when running a process as a daemon. It seems to me that running it inside GNU Screen is a viable alternative, since it guarantees to run the process after logging out of the server, output can be examined when logged back in, etc.

Is there any drawbacks of running e. g. a web server from inside Screen? I have a server process ran from inside Screen which became unreachable several times in the past weeks. I restarted it immediately, so I don’t know if it died because of some internal problem (fairly simple scripts, so I doubt) or it was the fault of Screen.

Joó Ádám
  • 255
  • 3
  • 10
  • What distribution are you using? – Tom O'Connor Feb 18 '13 at 00:26
  • @TomO'Connor It’s an Ubuntu 12.04 – Joó Ádám Feb 18 '13 at 00:48
  • It would help if you described the "quite a lot of precautions one is to take when running a daemon" and what problems you perceive. Specific concerns yield specific answers. – Andrew B Feb 18 '13 at 04:46
  • @AndrewB I was talking about all the steps described in http://en.wikipedia.org/wiki/Daemon_(computing)#Creation I thought I was specific enough: Screen seems to be a solution to the problem, but I never heard of anyone using it to run a service, so there may be something which makes it insufficient for the job and I’m not aware of. – Joó Ádám Feb 23 '13 at 14:51
  • Btw, I would be interested in the reason of the downvote on the question. Is that it does „not show any research effort; it is unclear or not useful”? – Joó Ádám Feb 23 '13 at 15:03

1 Answers1

12

Seems like the wrong solution, somehow.

If you're on Ubuntu, use Upstart.

If you're on Centos/RHEL/Other, take a look at using start-stop-daemon and the LSB init standard to properly daemonize a process, and then that'll enable you to use chkconfig to start/stop it automatically.

Tom O'Connor
  • 27,440
  • 10
  • 72
  • 148
  • You can do this for background processes as well as daemons (as Andrew B mentions the difference), and it's pretty straightforward to run background processes and detach them from a terminal by redirecting stdout/stderr and using `nohup` – Tom O'Connor Feb 18 '13 at 07:36
  • Thank you for the answer. I will check out Upstart (or init), I was just searching for the easiest way. Is nohup with redirection enough to secure the running of the process? – Joó Ádám Feb 23 '13 at 14:56