LinuxCommandLibrary

daemon

turn processes into Unix daemons

TLDR

Run a command as a daemon

$ daemon --name="[name]" [command]
copy
Run with automatic restart on crash
$ daemon --name="[name]" -r [command]
copy
Restart with limited attempts and delay
$ daemon --name="[name]" -r --attempts=2 --delay=10 [command]
copy
Run daemon with error logging
$ daemon --name="[name]" --errlog=[path/to/file.log] [command]
copy
Stop a daemon
$ daemon --name="[name]" --stop
copy
List all daemons
$ daemon --list
copy

SYNOPSIS

daemon [options] [--] command [args]

DESCRIPTION

daemon turns other processes into proper Unix daemons. It handles the standard daemonization tasks: forking, creating a new session, changing directory, closing file descriptors, and optionally respawning on exit.
Useful for running scripts or programs as background services without modifying the program itself.

PARAMETERS

--name name

Daemon name for identification
-r, --respawn
Restart if the command exits
--attempts n
Maximum restart attempts
--delay seconds
Delay between restart attempts
--errlog file
Log stderr to file
--output file
Log stdout to file
--stop
Stop the named daemon
--list
List running daemons

CAVEATS

Different from systemd services. For production services, consider using systemd units instead. PID file management should be coordinated to avoid conflicts.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community