/etc/init <-- upstart job
/etc/init.d/SCRIPT <-- sysinit
service <--- sysvinit
initctl list <--- upstart job
service service_name stop
service service_name start
Upstart
Upstart is an event-based replacement for the /sbin/init daemon (ubuntu 開發的)
initctl
opts
- start Start job.
- stop Stop job.
- restart Restart job.
- reload Send HUP signal to job.
- status Query status of job.
- list List known jobs.
Usage example:
i.e. 1
initctl list
rc stop/waiting tty (/dev/tty3) start/running, process 1217 tty (/dev/tty2) start/running, process 1215 tty (/dev/tty1) start/running, process 1213 tty (/dev/tty6) start/running, process 1225 tty (/dev/tty5) start/running, process 1223 tty (/dev/tty4) start/running, process 1219 plymouth-shutdown stop/waiting control-alt-delete stop/waiting rcS-emergency stop/waiting kexec-disable stop/waiting quit-plymouth stop/waiting rcS stop/waiting prefdm stop/waiting init-system-dbus stop/waiting splash-manager stop/waiting start-ttys stop/waiting rcS-sulogin stop/waiting serial stop/waiting
i.e. 2
initctl status tty6
tty6 start/running, process 1043
i.e. 3
initctl status 'tty'
initctl: Unknown parameter: TTY Usage: tty TTY=/dev/ttyX - where X is console id
在 /etc/init/start-ttys.conf
initctl start tty TTY=$tty
reload-configuration Reload the configuration of the init daemon.
show-config Show emits, start on and stop on details for job configurations.
tty6
start on (runlevel [23] and not-container)
stop on runlevel [!23]
check-config Check for unreachable jobs/event conditions.
起動
/etc/inittab
id:3:initdefault:
System initialization is started by /etc/init/rcS.conf
Individual runlevels are started by /etc/init/rc.conf
Ctrl-Alt-Delete is handled by /etc/init/control-alt-delete.conf
Terminal gettys are handled by /etc/init/tty.conf and /etc/init/serial.conf <---- /etc/sysconfig/init
Table 1: Well-Known Event Summary.
+----+--------------------------+------+------+------------------------+------+ |Ref | Event | Type | Emit | Time | Note | +----+--------------------------+------+------+------------------------+------+ | | all-swaps | S | M | > (5) | | | | control-alt-delete(7) | S | A | > (5) | A | | | container | S | C | > /run mounted | Q | | | dbus-activation | S | B | > D-Bus client request | | | | deconfiguring-networking | H | V | < non-local IFs down | P | | | desktop-session-start | H | D | > X(7) session created | B | | | desktop-shutdown | H | D | > X(7) session ended | O | | | device-not-ready | H | M | > (2) | N | | | drm-device-added | S | U | > (5) | C | | | failsafe-boot | S | X | > (7) and local IF | S | | 7 | filesystem | S | M | After last (1) | D | | | graphics-device-added | S | U | > (5) | C | | | keyboard-request(7) | S | A | > (5) | E | | | local-filesystems(7) | S | M | > (6) | | | | login-session-start | H | D | < DM running | F | | 1 | mounted(7) | H | M | > associated (2) | G | | 2 | mounting(7) | H | M | > (5) | H | | 3 | net-device-added | S | U | > (5) | C | | | net-device-changed | S | U | > (5) | C | | | net-device-down | S | F | < (4) | C | | 4 | net-device-removed | S | U | > (5) | C | | | net-device-up | S | F,N | > (3) | C | | | not-container | S | C | > /run mounted | Q | | | power-status-changed(7) | S | I | > (5) | I | | | recovery | S | G | Boot (<5) | R | | | remote-filesystems(7) | S | M | > (6) | | | | runlevel(7) | M | T | > (7) + (8) | | | | socket(7) | S | S | > socket connection | | | 5 | startup(7) | S | I | Boot | J | | | started(7) | S | I | > job started | K | | | starting(7) | H | I | < job starts | K | | 8 | static-network-up | S | N | > last static IF up | | | | stopped(7) | S | I | > job stopped | K | | | stopping(7) | H | I | < job stops | K | | | unmounted-remote- | H | V | > last remote FS | L | | | filesystems | | | unmounted | | | 6 | virtual-filesystems(7) | S | M | > last virtual FS (1) | M | +----+--------------------------+------+------+------------------------+------+ Key: 'DM' is an abbreviation for Display Manager. 'FS' is an abbreviation for filesystem. 'IF' is an abbreviation for Network Interface.
Table 2: Event Types.
+----+------------+---------------------+ |Ref | Event Type | Notes | +----+------------+---------------------+ | H | Hook | Blocking. Waits for | | | | events that start | | | | on or stop on this | | | | event. | | M | Method | Blocking task. | | S | Signal | Non-blocking. | +----+------------+---------------------+
Table 3: Event Emitters.
+----+----------------------------------+---------------------------------+ |Ref | Emitter | Notes | +----+----------------------------------+---------------------------------+ | A | System Administrator (initiator) | Technically emitted by init(8). | | B | dbus-daemon(1) | Run with "--activation=upstart" | | C | container-detect job | | | D | Display Manager | e.g. lightdm/gdm/kdm/xdm. | | F | ifup(8) or ifdown(8) | See /etc/network/. | | G | bootloader or initramfs | | | I | init(8) | | | M | mountall(8) | | | N | network-interface job | | | S | upstart-socket-bridge(8) | | | T | telinit(8), shutdown(8) | | | U | upstart-udev-bridge(8) | | | V | System V init system | | | X | failsafe job | | +----+----------------------------------+---------------------------------+
詳見:
init(5), init(8), and initctl(8)