Skip to content
RunStack
Wiki· Updated 19 Oct 2026

Cheat sheet: systemd

systemctl and journalctl: services, autostart, the journal, your own unit, timers instead of cron.

Services

systemctl status nginx
systemctl start | stop | restart | reload nginx
systemctl enable --now nginx               # start on boot and now
systemctl disable --now nginx
systemctl is-active nginx; systemctl is-enabled nginx
systemctl list-units --type=service --state=running
systemctl --failed                         # what has failed
systemctl cat nginx                        # unit file with all drop-ins
systemctl show nginx -p MainPID -p MemoryCurrent
systemctl daemon-reload                    # after editing unit files

Journal

journalctl -u nginx -f                     # follow
journalctl -u nginx --since "1 hour ago"
journalctl -u nginx -n 100 --no-pager
journalctl -b -p err                       # errors since the last boot
journalctl -b -1 -p err                    # ...since the previous one (why it rebooted)
journalctl -k | grep -i oom                # what the kernel killed for memory
journalctl --disk-usage
journalctl --vacuum-size=500M              # keep 500 MB of journal

Your own service

/etc/systemd/system/myapp.service:

[Unit]
Description=My app
After=network-online.target
Wants=network-online.target

[Service]
User=myapp
WorkingDirectory=/opt/myapp
EnvironmentFile=/opt/myapp/.env
ExecStart=/opt/myapp/bin/server --port 3000
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target
systemctl daemon-reload && systemctl enable --now myapp

Change a setting of someone else's service without touching its file:

systemctl edit nginx                       # creates override.conf
# [Service]
# LimitNOFILE=65536
systemctl restart nginx

Timers instead of cron

/etc/systemd/system/backup.service:

[Unit]
Description=Nightly backup

[Service]
Type=oneshot
ExecStart=/usr/local/bin/backup.sh

/etc/systemd/system/backup.timer:

[Unit]
Description=Nightly backup timer

[Timer]
OnCalendar=*-*-* 03:30:00
Persistent=true
RandomizedDelaySec=10m

[Install]
WantedBy=timers.target
systemctl daemon-reload && systemctl enable --now backup.timer
systemctl list-timers                      # when it runs next
systemctl start backup.service             # run now
systemd-analyze calendar "Mon *-*-* 09:00" # check a schedule

System

systemd-analyze blame | head               # what slows the boot
hostnamectl set-hostname web-1
timedatectl set-timezone Europe/Moscow
timedatectl set-ntp true