init is the parent of all processes on the system, it is executed by
the kernel and is responsible for starting all other processes; it is
the parent of all processes whose natural parents have died and it is
responsible for reaping those when they die.
Processes managed by init are known as jobs and are defined by files in
the /etc/init directory. See init(5) for more details on configuring
init(8) is an event-based init daemon. This means that jobs will be
automatically started and stopped by changes that occur to the system
state, including as a result of jobs starting and stopping.
This is different to dependency-based init daemons which start a speci-
fied set of goal jobs, and resolve the order in which they should be
started and other jobs required by iterating their dependencies.
For more information on starting and stopping jobs, as well as emitting
events that will automatically start and stop jobs, see the manual page
for the initctl(8) tool.
The primary event is the startup(7) event, emitted when the daemon has
finished loading its configuration. Other useful events are the start-
ing(7), started(7), stopping(7) and stopped(7) events emitted as jobs
Table 1: Job Goals and State Transitions.
| | Goal |
|Current State | start | stop |
|waiting | starting n/a |
|starting | pre-start stopping |
|pre-start | spawned stopping |
|spawned | post-start stopping |
|post-start | running stopping |
|running | stopping pre-stop / stopping (*) |
|pre-stop | running stopping |
|stopping | killed killed |
|killed | post-stop post-stop |
|post-stop | starting waiting |
(*) If there is a script or exec section and this process is running,
state will be 'pre-stop', else it will be 'stopping'.
5 Any jobs whose 'start on' (or 'stop on') condition would be satis-
fied by this job starting are started (or stopped respectively).
6 The starting(7) event completes.
7 The state is changed from 'starting' to 'pre-start'.
8 If the pre-start stanza exists, the pre-start process is spawned.
9 If the pre-start process fails, the goal is changed from 'start' to
'stop', and the stopping(7) and stopped(7) events are emitted with
appropriate variables set denoting the error.
10 Assuming the pre-start did not fail or did not call "stop", the main
process is spawned.
11 The state is changed from 'pre-start' to 'spawned'.
12 Upstart then ascertains the final PID for the job which may be a
descendent of the immediate child process if expect fork or expect
daemon has been specified.
13 The state is changed from 'spawned' to 'post-start'.
14 If the post-start stanza exists, the post-start process is spawned.
15 The state is changed from 'post-start' to 'running'.
16 The started(7) event is emitted.
For services, when this event completes the main process will now be
fully running. If the job refers to a task, it will now have com-
pleted (successfully or otherwise).
17 Any jobs whose 'start on' (or 'stop on') condition would be satis-
fied by this job being started are started (or stopped respec-
Stopping a Job
1 Assuming the job is fully running, it will have a goal of 'start'
and a state of 'running' (shown as 'start/running' by the initctl(8)
list and status commands).
2 The goal is changed from 'start' to 'stop' indicating the job is
attempting to stop.
3 The state is changed from 'running' to 'pre-stop'.
4 If the pre-stop stanza exists, the pre-stop process is spawned.
5 The state is changed from 'pre-stop' to 'stopping'.
See signal(7) and init(5).
ii Upstart waits for up to "kill timeout" seconds (default 5 sec-
onds) for the process to end.
If the process is still running after the timeout, a SIGKILL sig-
nal is sent to the process which cannot be ignored and will
forcibly stop the processes in the process group.
9 The state is changed from 'killed' to 'post-stop'.
10 If the post-stop stanza exists, the post-stop process is spawned.
11 The state is changed from 'post-stop' to 'waiting'.
12 The stopped(7) event is emitted.
When this event completes, the job is fully stopped.
13 Any jobs whose 'start on' (or 'stop on') condition would be satis-
fied by this job being stopped are started (or stopped respec-
System V compatibility
The Upstart init(8) daemon does not keep track of runlevels itself,
instead they are implemented entirely by its userspace tools. The
event emitted to signify a change of runlevel is the runlevel(7) event.
For more information see its manual page.
Options are passed to init(8) by placing them on the kernel command-
Add the specified directory to the default directory or directo-
ries that job configuration files will be read from. This option
may be specified multiple times which will result in job config-
uration files being loaded from each directory specified (which
must exist). Directories will be searched for jobs in the spec-
ified order after the default directories have been searched.
Note that if this option is used in combination with --confdir,
or --prepend-confdir, regardless of the order of the options on
the command-line, the append directories will be added after the
Read job configuration files from a directory other than the
default (/etc/init for process ID 1). This option may be speci-
fied multiple times which will result in job configuration files
being loaded from each directory specified (which must exist).
Directories will be searched for jobs in the specified order.
Do not honour the cgroup stanza. If specified, this stanza will
be ignored for any job which specifies it: the job processes
will not be placed in the cgroup specified by the stanza and the
job itself will not wait until the cgroup manager has started
before starting itself. See init(5) for further details.
Do not connect to a D-Bus bus.
Stop jobs from inheriting the initial environment. Only meaning-
ful when running in user mode.
Write job output log files to a directory other than
/var/log/upstart (system mode) or $XDG_CACHE_HOME/upstart (user
Disable logging of job output. Note that jobs specifying 'con-
sole log' will be treated as if they had specified 'console
none'. See init(5) for further details.
Disable chroot sessions.
Suppress emission of the initial startup event. This option
should only be used for testing since it will stop the init(8)
daemon from starting any jobs automatically.
Add the specified directory to the directory or directories that
job configuration files will be read from. This option may be
specified multiple times which will result in job configuration
files being loaded from each directory specified (which must
exist). Directories will be searched for jobs in the specified
order before the default directories have been searched.
Note that if this option is used in combination with --confdir,
or --append-confdir, regardless of the order of the options on
the command-line, the prepend directories will be added before
the other directories.
Connect to the D-Bus session bus. This should only be used for
Specify a different initial startup event from the standard
Outputs version information and exits.
init is not normally executed by a user process, and expects to have a
process id of 1. If this is not the case, it will actually execute
telinit(8) and pass all arguments to that. See that manual page for
further details. However, if the --user option is specified, it will
run as a Session Init and read alternative configuration files and man-
age the individual user session in a similar fashion.
Sending a Session Init a SIGTERM signal is taken as a request to shut-
down due to an impending system shutdown. In this scenario, the Session
Init will emit the session-end event and request all running jobs
stop. It will attempt to honour jobs kill timeout values (see init(5)
for further details). Note however that system policy will prevail: if
jobs request timeout values longer than the system policy allows for
complete system shutdown, it will not be possible to honour them before
the Session Init is killed by the system.
When run as a user process, the following variables may be used to find
job configuration files:
See User Session Mode in init(5) for further details.
Written by Scott James Remnant <firstname.lastname@example.org>
Report bugs at <https://launchpad.net/upstart/+bugs>
Copyright (C) 2009-2013 Canonical Ltd.
This is free software; see the source for copying conditions. There is
NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
Man Pages Copyright Respective Owners. Site Copyright (C) 1994 - 2019
All Rights Reserved.