start-stop-daemon [option...] command
start-stop-daemon is used to control the creation and termination of system-level processes. Using one of the matching options, start-stop-daemon can be configured to find existing instances of a running process.
Note: unless --pid or --pidfile are specified, start-stop-daemon behaves similar to killall(1). start-stop-daemon will scan the process table looking for any processes which match the process name, parent pid, uid, and/or gid (if specified). Any matching process will prevent --start from starting the daemon. All matching processes will be sent the TERM signal (or the one specified via --signal or --retry) if --stop is specified. For daemons which have long-lived children which need to live through a --stop, you must specify a pidfile.
If timeout is specified instead of schedule, then the schedule signal/timeout/KILL/timeout is used, where signal is the signal specified with --signal.
schedule is a list of at least two items separated by slashes (/); each item may be -signal-number or [-]signal-name, which means to send that signal, or timeout, which means to wait that many seconds for processes to exit, or forever, which means to repeat the rest of the schedule forever if necessary.
If the end of the schedule is reached and forever is not specified, then start-stop-daemon exits with error status 2. If a schedule is specified, then any signal specified with --signal is ignored.
When using the --status command, the following status codes are returned:
Start the food daemon, unless one is already running (a process named food, running as user food, with pid in food.pid):
start-stop-daemon --start --oknodo --user food --name food \ --pidfile /run/food.pid --startas /usr/sbin/food \ --chuid food -- --daemon
Send SIGTERM to food and wait up to 5 seconds for it to stop:
start-stop-daemon --stop --oknodo --user food --name food \ --pidfile /run/food.pid --retry 5
Demonstration of a custom schedule for stopping food:
start-stop-daemon --stop --oknodo --user food --name food \ --pidfile /run/food.pid --retry=TERM/30/KILL/5