LinuxCommandLibrary

start-stop-daemon

Start, stop, and manage daemon processes

SYNOPSIS

start-stop-daemon [options] command

PARAMETERS

--start
    Start the daemon process.

--stop
    Stop the daemon process.

--status
    Check if the daemon is running and return an exit code (0 if running, appropriate non-zero otherwise).

--help
    Display help information.

--version
    Display version information.

--quiet
    Suppress most informational messages.

--oknodo
    Exit with status 0 even if no process is found (used with --stop).

--chuid
    Change to this user/uid before starting the process.

--chgid
    Change to this group/gid before starting the process.

--user
    Check for processes owned by this user/uid.

--group
    Check for processes owned by this group/gid.

--name
    Check for processes with this name (useful when the executable path changes).

--pidfile
    Read the PID from this file.

--exec
    Check for processes executing this pathname.

--startas
    Execute this pathname to start the process.

--make-pidfile
    Create the pidfile specified by --pidfile.

--signal
    Signal to send to stop the process (default: TERM).

--retry
    Retry stopping the process after sending the signal.

--remove-pidfile
    Remove the pidfile after stopping the process.

--no-close
    Do not close any file descriptors on start.

--background
    Go to the background. Implies --no-close.

--nicelevel
    Changes the priority (nice level) of the process.

--umask
    Changes the umask of the process before starting.

--verbose
    Display verbose messages.

DESCRIPTION

start-stop-daemon is a utility for controlling the startup and shutdown of system daemons. It's primarily used in Debian-based systems' init scripts, providing a consistent interface for managing background processes. It avoids common pitfalls of simple process management, such as preventing multiple instances of a daemon from running and ensuring clean shutdown. start-stop-daemon searches for processes matching specific criteria (user, group, executable, name) and then takes actions like starting the daemon (if not already running) or stopping it (gracefully, if possible). The command offers various options to configure how processes are searched for, and how start/stop actions are performed, allowing a very flexible way to manage daemon processes. It's preferred over simple `kill` commands due to its ability to send specific signals and check for successful process termination. Its reliability helps ensure system stability and predictable daemon behavior. It is often used in system initialization scripts, and helps the system maintain process integrity.

CAVEATS

Using incorrect criteria can lead to unintended stopping of processes. Always verify the command before running in production.

RETURN CODES

start-stop-daemon returns 0 on success. A non-zero return code indicates a failure to start or stop the process, or that no process was found when --oknodo was not used. The status command returns 0 if daemon is running and a non-zero return code otherwise.

SIGNAL HANDLING

start-stop-daemon provides detailed control over the signals used to stop processes. It provides the ability to customize the signal, and to retry with different signals after a timeout. The default signal is TERM.
Use `kill -l` to get a list of all available signals.

HISTORY

start-stop-daemon was originally developed for the Debian operating system to provide a consistent and reliable way to manage daemon processes within init scripts.
It aims to solve issues arising from simple process management techniques, such as orphaned processes or multiple instances of the same daemon.
Its design prioritizes robustness and predictability, making it a core component of Debian's system initialization. Over time it has been widely adopted in other distributions.

The command's flexibility stems from its ability to search for processes based on multiple criteria (user, name, executable) and its support for different signaling and retry mechanisms during the stopping process. This allows administrators to tailor the process management to the specific needs of their daemons.

SEE ALSO

kill(1), ps(1), systemctl(1)

Copied to clipboard