man > daemon(7)

```html

NAME

daemon(1) β€” turns other processes into daemons.

πŸš€ Quick Reference

Use Case Command Description
Run a command as a daemon daemon [options] -- cmd arg... Turn any command into a background daemon process.
Run a named daemon with auto‑restart daemon --name mydaemon --respawn -- /path/to/command Ensure a single instance and respawn on failure.
Check if a named daemon is running daemon --name mydaemon --running Exit with success if running, failure otherwise.
Stop a named daemon daemon --name mydaemon --stop Send SIGTERM to the daemon and its client.
Restart a named daemon’s client daemon --name mydaemon --restart Send SIGUSR1 to trigger a restart (requires --respawn).
List all named daemons daemon --list Show currently running named daemons.
Run a daemon in foreground with pseudo‑terminal daemon --foreground --pty -- cmd Keep the client connected to a controlling terminal.
Run as a different user daemon --user=user:group -- cmd Drop privileges (root only) before starting the client.

SYNOPSIS

usage: daemon [options] [--] [cmd arg...]

options:

DESCRIPTION

daemon(1) turns other processes into daemons. There are many tasks that need to be performed to correctly set up a daemon process. This can be tedious. daemon performs these tasks for other processes.

The preparatory tasks that daemon performs for other processes are:

OPTIONS

General Options

Configuration Options

Privilege and Environment Options

Respawn and Lifecycle Options

Foreground and Terminal Options

Messaging Options

Named Daemon Control Options

As with all other programs, a -- argument signifies the end of options. Any options that appear on the command line after -- are part of the client command.

EXPANSION

Some simple shell-like expansion is performed internally on the arguments of the command line options with a text argument (but not the options with a numeric argument).

Environment variable notation, such as $VAR or ${VAR}, is expanded. Then user home directory notation, such as ~ or ~user, is expanded. File name expansion (i.e. globbing) is NOT performed internally. Neither are any of your login shell's other wonderful expansions. This is very basic.

This might not be of much use on the command line, since daemon is normally invoked via a shell, which will first perform all of its usual expansions. It might even be undesirable to perform expansion internally after the shell has already done so (e.g. if you refer to any directory names that actually contain the '$' character, or if you use any environment variables whose values contain the '$' character, which is unlikely).

But it can be useful in configuration files. See the FILES section below for more details. It can also be useful when daemon is invoked directly by another program without the use of a shell.

By default, environment variable expansion is not performed for the root user, even if the environment variable was defined in the configuration files. The --idiot option can be used to change this behaviour, and allow the expansion of environment variables for the root user. Home directory notation expansion is performed for all users.

FILES

Each line of the configuration file is either an environment variable definition, or a configuration directive.

Environment variable definitions consist of the variable name, followed immediately by '=' and the value of the variable. They look like they do in shell, except that there is no quoting or other shell syntax. Environment variable values can include simple environment variable notation (e.g. $VAR or ${VAR}), and user home directory notation (e.g. ~ or ~user). These will be expanded internally by daemon. See the EXPANSION section above for more details.

Note that any environment variables that are defined in the configuration file, which are subsequently used explicitly in another environment variable definition or in an option argument, will have these expansions performed multiple times. Avoid environment variables whose values can change again if expansion is performed multiple times.

Example:

PATH=/usr/bin:/usr/sbin:$HOME/bin:~app/bin
PIDFILES=~/.run

Configuration directives consist of a client name (for options that apply to a single client), or '*' (for generic options that apply to all clients), followed by spaces and/or tabs, followed by a comma-separated list of options. Any option arguments must not contain any commas. The commas that separate options can have spaces and tabs before and after them. Option arguments that are text (but not numbers) can include simple environment variable notation (e.g. $VAR or ${VAR}), and user home directory notation (e.g. ~ or ~user). These will be expanded internally by daemon. See the EXPANSION section above for more details.

Blank lines and comments ('#' to end of the line) are ignored. Lines can be continued with a '\' character at the end of the line.

Example:

*       errlog=daemon.err,output=local0.err,core
test1   syslog=local0.debug,debug=9,verbose=9,respawn
test2   syslog=local0.debug,debug=9, \
        verbose=9,respawn, \
        pidfiles=$PIDFILES

The command line options are processed first, to look for a --config option. If no --config option was supplied, the default configuration files, /etc/daemon.conf and /etc/daemon.conf.d/*, are used. On BSD systems (except macOS), the default configuration files are /usr/local/etc/daemon.conf and /usr/local/etc/daemon.conf.d/*. On macOS when installed via macports, the default configuration files are /opt/local/etc/daemon.conf and /opt/local/etc/daemon.conf.d/*. If the user has their own configuration files, ~/.daemonrc and ~/.daemonrc.d/*, they are also used.

If the configuration files contain any generic ('*') entries, their options are applied in order of appearance. If the --name option was supplied, and the configuration files contain any entries for the given name, those options are then applied in order of appearance.

Finally, the command line options are applied again. This ensures that any generic options apply to all clients by default. Client-specific options override generic options. User options override system-wide options. Command line options override everything else.

Note that the configuration files are not opened and read until after any --chroot and/or --user command line options are processed. This means that the configuration file paths and the client's file path must be relative to the --chroot argument. It also means that the configuration files and the client executable must be readable/executable by the user specified by the --user argument. It also means that the --chroot and --user options must not appear in the configuration file. Also note that the --name option must not appear on the right hand side in the configuration file either.

MESSAGING

The --errlog, --dbglog, --output, --stdout and --stderr options all take an argument that can be either a syslog destination of the form "facility.priority" or the path to a file. Here are the lists of syslog facilities and priorities:

If the path to a file is supplied instead, bear in mind the fact that daemon(1) changes to the root directory by default, and so the file path should be an absolute path (or relative to the --chroot and/or --chdir option argument). Otherwise, daemon(1) will attempt to create the file relative to its current directory. You might not have permissions to do that, or want to even if you do.

CAVEAT

SEE ALSO

libslack(3), daemon(3), coproc(3), pseudo(3), init(8), inetd(8), fork(2), umask(2), setsid(2), chdir(2), chroot(2), setrlimit(2), setgid(2), setuid(2), setgroups(2), initgroups(3), syslog(3), kill(2), wait(2), systemd-logind(8), elogind(8)

AUTHOR

20210304 raf <raf AT raf.org>

```
daemon(7)
NAME πŸš€ Quick Reference SYNOPSIS DESCRIPTION OPTIONS
General Options Configuration Options Privilege and Environment Options Respawn and Lifecycle Options Foreground and Terminal Options Messaging Options Named Daemon Control Options
EXPANSION FILES MESSAGING CAVEAT SEE ALSO AUTHOR

Generated by phpman v4.9.26-1-g511901d · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-31 00:05 @216.73.217.152
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 Transitional!Valid CSS!
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format

^_top_^