Analyze boot time systemd
Show top 20 units by initialization time
systemd-analyze blame | head -20
more systemd
all 26 commands →
Draw boot dependency graph
systemd-analyze dot --require | dot -Tsvg > boot.svg && open boot.svg
Create a simple service unit
cat > /etc/systemd/system/myapp.service <<EOF
[Unit]
Description=My App
After=network.target
[Service]
ExecStart=/usr/bin/myapp
Restart=always
RestartSec=5
User=appuser
[Install]
WantedBy=multi-user.target
EOF
Run one-shot as another user
systemd-run --uid=1000 --gid=1000 --wait /usr/bin/myapp --task
Create systemd timer
cat > /etc/systemd/system/backup.timer <<EOF
[Unit]
Description=Daily backup
[Timer]
OnCalendar=daily
Persistent=true
[Install]
WantedBy=timers.target
EOF
Set memory limit on service
systemctl set-property myapp.service MemoryMax=512M CPUQuota=50%