start-stop-daemon(8)
โจ start-stop-daemon(8) โ the dpkg suite's little process-wrangler โจ
okay bestie, gather round, because this one is literally the backstage crew of your whole system ๐ it lives in the dpkg suite, and it's the thing that starts your daemons up and shuts them down. no cap.
๐ NAME ๐
start-stop-daemon โ start and stop system daemon programs
like, that's the whole job. it starts them. it stops them. iconic behaviour, honestly ๐ซถ
๐ธ SYNOPSIS ๐ธ
start-stop-daemon [option...] command
that's it, that's the shape of it: a pile of options, then one command. make it make sense and you're golden โจ
๐ DESCRIPTION ๐
so start-stop-daemon is the girl who controls the creation and termination of system-level processes. that's her whole thing. and by using one of the matching options, she can be configured to find existing instances of a running process โ like, she can go "oh, is that little guy already running? hold on, let me look" ๐
Note: unless you pass--pidor--pidfile,start-stop-daemonbehaves similar tokillall(1).
okay so here's what that actually means, because it matters:
start-stop-daemonwill 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
--startfrom starting the daemon. so no doubling up, she's not doing that today ๐ - All matching processes will be sent the
TERMsignal (or the one you specified via--signalor--retry) if--stopis specified. - and this one is important: for daemons which have long-lived children which need to live through a
--stop, you must specify a pidfile. like, must. no shortcuts. periodt ๐
๐ COMMANDS ๐
pick your fighter. one of these goes at the end of your option pile ๐
-S,--start [--] argumentsโ Checks for the existence of a specified process. If such a process exists,start-stop-daemondoes nothing, and exits with error status 1 (or 0 if--oknodois specified ๐). If such a process does not exist, she starts an instance, using either the executable specified by--execor, if specified, by--startas. Any arguments given after--on the command line are passed unmodified to the program being started โ so they arrive exactly as you typed them, no edits, no glow-up, nothing ๐ฆ-K,--stopโ Checks for the existence of a specified process. If such a process exists,start-stop-daemonsends it the signal specified by--signal, and exits with error status 0. If such a process does not exist,start-stop-daemonexits with error status 1 (or 0 if--oknodois specified). And if--retryis specified, thenstart-stop-daemonwill check that the process(es) have terminated โ she's not just yeeting the signal and walking away, she's staying to make sure it actually landed ๐-T,--statusโ Check for the existence of a specified process, and returns an exit status code, according to the LSB Init Script Actions (since version1.16.1). main-character energy from the LSB era, we love to see it โญ-H,--helpโ Show usage information and exit. the "bestie, how do I even" button ๐-V,--versionโ Show the program version and exit. for when you need to know who you're dealing with ๐ฅ
more coming, don't go anywhere ๐
โจ OPTIONS โจ
okay bestie, this is THE section. every single flag, every letter, all of it. buckle up ๐
๐ Matching options ๐
these are the "which process are we even talking about" flags. pick your fighter (or stack several for accuracy, iykyk).
--pidpid โ checks for a process with that exact pid (since version 1.17.6). the pid must be a number greater than 0. no zeroes, no negatives, periodt.--ppidppid โ same energy but for the parent pid, aka ppid (since version 1.17.7). and yeah, the ppid must be a number greater than 0 too.-p,--pidfilepidfile โ checks whether a process has created the file pidfile.
Note: using this match all by itself might cause unintended processes to get acted on ๐ญ โ if the old process died without being able to remove the pidfile, you're basically matching a ghost.
Warning: this one is serious, no cap. using this match with a world-writable pidfile, or using it alone with a daemon that writes its pidfile as an unprivileged (non-root) user, will be refused with an error (since version 1.19.3), because it is a genuine security risk โ because either any user can write to it, or, if the daemon gets compromised, the contents of the pidfile cannot be trusted, and then a privileged runner (such as an init script executed as root ๐) would end up acting on any system process. the one sanctuary, the single exception, is /dev/null โ that's exempt from these checks ๐ซถ
-x,--execexecutable โ checks for processes that are instances of this executable. bestie, the executable argument should be an absolute pathname.
Note: this might not work as intended with interpreted scripts, since the executable will point to the interpreter ๐. also take into account that processes running from inside a chroot will also be matched, so you might need other match restrictions to narrow things down.
-n,--nameprocess-name โ checks for processes named process-name. that's usually the process filename, but a process could have changed it itself, soโฆ yeah.
Note: on most systems this info is retrieved from the process comm name from the kernel, which tends to have a relatively short length limit โ assuming more than 15 characters is non-portable. so maybe don't name your daemon supercalifragilistic-daemon and expect it to match ๐
-u,--userusername|uid โ checks for processes owned by the user specified by username or uid.
Note: using this match alone will cause all processes matching that user to be acted on. all of them. the entire roster. be so for real before you do that.
๐ธ Generic options ๐ธ
-g,--groupgroup|gid โ changes to group or gid when starting the process.-s,--signalsignal โ with--stop, this is the signal sent to the processes being stopped. default isTERM.-R,--retrytimeout|schedule โ with--stop, this tells start-stop-daemon to check whether the process(es) actually finish. it checks repeatedly whether any matching processes are running, until none are. if the processes don't exit, it then takes further action as determined by the schedule.
if you give a timeout instead of a schedule, then it uses the schedule signal/timeout/KILL/timeout, where signal is whatever you set with --signal.
a schedule is a list of at least two items separated by slashes (/). each item can be:
-signal-numberor[-]signal-nameโ meaning "send that signal", ortimeoutโ wait that many seconds for processes to exit, orforeverโ 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. and heads up: if a schedule is specified, then any signal set with --signal is ignored.
-a,--startaspathname โ with--start, this starts the process specified by pathname. if you don't specify it, it defaults to whatever argument you gave to--exec.-t,--testโ prints the actions that would be taken and sets the appropriate return value, but takes no action. a lil dress rehearsal ๐-o,--oknodoโ returns exit status0instead of1if no actions are (or would be) taken.-q,--quietโ no informational messages, only error messages. silent but deadly โจ-c,--chuidusername|uid[:group|gid] โ changes to this username/uid before starting the process. you can also specify a group by appending a:, then the group or gid in exactly the same way you would for thechown(1)command (user:group). if a user is specified without a group, the primary GID for that user is used. when you use this option you must realize that the primary and supplemental groups are set as well, even if the--groupoption isn't specified.--groupis only for groups that the user isn't normally a member of (like adding per-process group membership for generic users likenobody).-r,--chrootroot โ changes directory and chroots to root before starting the process. please note that the pidfile is also written after the chroot, so picture that.-d,--chdirpath โ changes directory to path before starting the process. this is done after the chroot if the-r/--chrootoption is set. when not specified, start-stop-daemon changes directory to the root directory before starting the process.-b,--backgroundโ typically used with programs that don't detach on their own. this option forces start-stop-daemon to fork before starting the process, and forces it into the background. main character behavior.
Note: the exit status from a late unexpected failure during process initialization cannot be checked, unless the --notify-await option is used. it is intended for programs that either make no sense daemonizing on their own, or where it's not feasible or not desired to add the daemonizing and notification code for them to do this themselves.
--notify-awaitโ waits for the background process to send a readiness notification before considering the service started (since version 1.19.3). this option can only be used with--background.
this implements parts of the systemd readiness protocol, as specified in the sd_notify(3) manual page. these variables are supported:
READY=1โ the program is ready to give service, so we can exit safely. ๐ฅณEXTEND_TIMEOUT_USEC=numberโ the program requests to extend the timeout by number microseconds. this resets the current timeout to the specified value.ERRNO=numberโ the program is exiting with an error. do the same and print the user-friendly string for the errno value.
--notify-timeouttimeout โ sets a timeout for the--notify-awaitoption (since version 1.19.3). when the timeout is reached, start-stop-daemon exits with an error code, and no readiness notification will be awaited. the default is60seconds.-C,--no-closeโ does not close any file descriptor when forcing the daemon into the background (since version 1.16.5). used for debugging purposes to see the process output, or to redirect file descriptors to log the process output. only relevant when using--background.-O,--outputpathname โ redirects stdout and stderr to pathname when forcing the daemon into the background (since version 1.20.6). only relevant when using--background.-N,--nicelevelint โ alters the priority of the process before starting it.-P,--procschedpolicy:priority โ alters the process scheduler policy and priority of the process before starting it (since version 1.15.0). the priority can optionally be specified by appending a:followed by the value; the default priority is0. currently supported policy values areother,fifoandrr.
might do nothing at all on some systems, where POSIX process scheduling is not supported ๐
-I,--ioschedclass:priority โ alters the IO scheduler class and priority of the process before starting it (since version 1.15.0). the priority can optionally be specified by appending a:followed by the value; the default priority is4, unless class isidle, and then priority will always be7. currently supported values for class areidle,best-effortandreal-time.
might also do nothing on some systems, where Linux IO scheduling is not supported ๐
-k,--umaskmask โ sets the umask of the process before starting it (since version 1.13.22).-m,--make-pidfileโ used when starting a program that doesn't create its own pid file. this option makes start-stop-daemon create the file referenced with--pidfileand place the pid into it just before executing the process. note, the file will only be removed when stopping the program if--remove-pidfileis used.
Note: this feature may not work in all cases, bestie. most notably when the program being executed forks from its main process. because of this, it is usually only useful when combined with the --background option.
--remove-pidfileโ used when stopping a program that doesn't remove its own pid file (since version 1.17.19). this option makes start-stop-daemon remove the file referenced with--pidfileafter terminating the process.-v,--verboseโ prints verbose informational messages. chatty era ๐ฃ๏ธ
๐ฆ EXIT STATUS ๐ฆ
0โ the requested action was performed. if--oknodowas specified, it's also possible that nothing had to be done โ which can happen when--startwas specified and a matching process was already running, or when--stopwas specified and there were no matching processes.1โ if--oknodowas not specified and nothing was done.2โ if--stopand--retrywere specified, but the end of the schedule was reached and the processes were still running. ๐ฌ3โ any other error.
when you're using the --status command, these are the status codes that come back:
0โ program is running.1โ program is not running and the pid file exists.3โ program is not running.4โ unable to determine program status.
๐ EXAMPLE ๐
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
a lil 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
and that's the whole page, bestie ๐ this was version 1.23.7 of the start-stop-daemon(8) manual, dated 2026-09-16. go forth and manage your daemons responsibly, ily ๐ซถโจ
๐ฆ where this page comes from
- ubuntu stonking: dpkg 1.23.7ubuntu2 ยท GPL-2.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms