Skip to content

Quiz: systemd

← Back to quiz index

4 questions

L0 (2 questions)

1. How do you check why a service failed to start?

Show answer journalctl -u -e to see recent logs. systemctl status for quick overview.

2. What are the main systemd unit types and when do you use each?

Show answer service: long-running daemons (nginx, postgresql). timer: scheduled tasks (replaces cron). socket: socket-activated services (on-demand start). target: groups of units (multi-user.target replaces runlevels). mount/automount: filesystem mounts. path: trigger on file/directory changes. slice: resource control grouping (cgroups). Most daily work involves .service and .timer units.

L1 (1 questions)

1. How do you troubleshoot a systemd service that keeps restarting?

Show answer 1. systemctl status — see last exit code and restart count.
2. journalctl -u -e —no-pager — see recent logs for the crash reason.
3. Check Restart= and RestartSec= in the unit file (systemctl cat ).
4. Check resource limits: LimitNOFILE, MemoryMax.
5. Run the binary manually to reproduce.
6. Check for dependency failures: systemctl list-dependencies . StartLimitBurst and StartLimitIntervalSec control how many rapid restarts before systemd gives up.

L2 (1 questions)

1. How do you create a systemd timer to replace a cron job?

Show answer Create two files: a .timer and a matching .service. Timer: [Timer] OnCalendar=*-*-* 02:00:00 (daily at 2am) or OnBootSec=5min (5 min after boot). Persistent=true reruns missed executions after downtime. Service: [Service] Type=oneshot, ExecStart=/path/to/script. Enable with: systemctl enable --now mytask.timer. Advantages over cron: dependency ordering, resource limits, logging via journal, calendar expressions with randomized delay.