Jump to content

Talk:Run as a daemon or service: Difference between revisions

Line 32:
::: also there are only few developers writing the daemon, but many more sysadmins running it. so any complication that is taken away from the sysadmin and moved to the developers is a win in the long run.
::: but the main point really is to show of the capabilities of languages here. using a shell script would defeat that purpose and would not fit on rosettacode. it also would not be portable.--[[User:EMBee|eMBee]] 15:15, 17 November 2011 (UTC)
:::: Huh?
:::: First: daemons should be run from inittab or the rc directories which are run by init. If you don't do that, you lose your daemon on every reboot.
:::: Second: you could easily abstract the shell script:
:::: <lang bash>$ cat >/usr/local/bin/detach_from_shell; chmod +x /usr/local/bin/detach_from_shell
#!/bin/sh
if [ -n "$1" ]; then (
"$@" </dev/null >/dev/null 2>&1&
) else
>&2 echo 'Usage:'
>&2 echo 'detach_from_shell program [arguments]'
exit 1
fi</lang>
:::: Now you have a shell command to run a program "as a daemon" without actually installing it on the system so that it runs reliably (e.g. so it comes back up after a reboot...)
:::: Meanwhile, if you are not running the program from the shell, there is no reason to detach it from the shell context. --[[User:Rdm|Rdm]] 17:50, 17 November 2011 (UTC)
6,951

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.