Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux daemon vs foreground application

What are the advantages of "daemonizing" a server application over running the program in console mode?

like image 307
rxjsisfine Avatar asked Dec 18 '11 21:12

rxjsisfine


3 Answers

Having it run as a daemon means you can

  • log out without loosing the service (which saves some resources)

  • do not risk loosing the service from an accidental ctrl-c

  • does not offer a minor security risk from someone accessing the terminal, hitting ctrl-c and taking your session

Essentially all 'real' services that are running 'in production' (as opposed to debug mode) run that way.

like image 178
Dirk Eddelbuettel Avatar answered Oct 03 '22 10:10

Dirk Eddelbuettel


I think it is preventing from accidentally closing an app and you have one more terminal free. But I personally don't see big difference between "screen" program and "daemonizing"

like image 26
ahaw Avatar answered Oct 03 '22 08:10

ahaw


The main point would be to detach the process from the terminal so that the process does not terminate when the user logs out from the terminal. If you run a program in console mode, it will terminate when you log out, because this is the default behavior for a process when it receives a SIGHUP signal.

Note that there is more to writing a daemon than just calling daemon(3). See How to write a unix daemon for more information.

like image 28
John Jeffery Avatar answered Oct 03 '22 08:10

John Jeffery