Visit me elsewhere:

systemd

runlevels
=> Upstart
==> Systemd

Upstart vs Systemd comparison

Upstart Systemd
“jobs” “units”
greedy event-based lazy dependency-based
only start if a dependency of sth

Commands

systemctl start/stop/restart/status 
systemctl status
systemd-analyze verify 
systemctl --state=failed

journalctl -u 
journalctl -u  -f
systemctl list-dependencies --all

Example Systemd service

/lib/systemd/system/foo.service:

[Unit]
Description=Job that runs the foo daemon
Documentation=man:foo(1)

[Service]
Type=forking
Environment=statedir=/var/cache/foo
ExecStartPre=/usr/bin/mkdir -p ${statedir}
ExecStart=/usr/bin/foo-daemon --arg1 "hello world" --statedir ${statedir}

[Install]
WantedBy=multi-user.target

Additional settings

Foreground/Background

Foreground [default]: Type=simple

Background: Type=forking

Environment Variables File

Mandatory environment variable file: EnvironmentFile=/etc/default/foo

Optional environment variable file: EnvironmentFile=-/etc/default/foo

Reference Links