systemd is an init daemon
- but, manage services, too
- also, systemd timers to schedule events
- OS init bootstrap is a hierarchy
- tree structure of dependencies
- Targets
- expressed as Units
- daemons represented as Service units
command quickref:
$ sudo systemctl
First:
$ tree /etc/systemd | less
Units
$ man systemd.unit
Service
Socket
Target
Timer
Unit-file
- all have [Unit] -section
- Description=
- After= for determining target after which unit is loaded
$ less /lib/systemd/system/dbus.service
- Requires
- Wants
- Conflicts
/etc/systemd/system - local conf
/run/systemd/system - runtimes/volatile
/lib/systemd/system - distribution wide conf
systemctl
- command line interface to systemd
- first try:
$ sudo systemctl status
enable
- creates a symlink from .service file
- Possible if unit conf contains correct [Install] target
disable
- removes the symlink
start
stop
reload
Depending on unit conf, may not happen
Service
Controls a daemon
.service postfix
[Service] section in conf
- ExecStart=
- ExecReload=
- FailureAction=reboot
- Restart=
- Type= simple|oneshot|forking
- WatchDog=
Env-var MAINPID of this units main process
- can be used to kill the process
Socket
- unit waits for an event, once event triggered starts a service
- network & local sockets, FIFOs
- Listen[Stream|FIFO|...]
- socket foo.socket starts foo.service (naming)
- unless Service= line configured.
Target
.target postfix
- a Unit that lists dependencies on other Targets
- After=
- WantedBy=
- Unit A Requires Unit B and After Unit B and Require Unit C
--> startup order B A C
Timer
- time-triggered