Skip to content
Tutorials Center
My learning

Topics

Linux Command Reference · Systemd and Logging (Read-Only)

systemd-analyze

Use systemd-analyze to find slow boot services with blame and critical-chain, check unit files with verify, test OnCalendar with calendar, and score security.

systemd-analyze inspects how a systemd machine started and how its units are configured. Without arguments it prints the boot time split into firmware, loader, kernel and userspace. Its subcommands answer the questions you ask when a machine boots slowly or a unit file misbehaves: which service took longest, what the boot was waiting for, whether a unit file has mistakes, and how exposed a service is.

It needs a running systemd, so the real commands are read-only in the sandbox. The examples process sample output of blame and critical-chain, which is plain text you can sort and total.

Terminal
systemd-analyze
systemd-analyze blame
systemd-analyze critical-chain
systemd-analyze verify /etc/systemd/system/api.service

Try it

Bash Rank slow units from sample blame output

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Bash Follow a critical chain (sample)

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Syntax

Terminal
systemd-analyze [time]
systemd-analyze blame
systemd-analyze critical-chain [UNIT...]
systemd-analyze verify FILE...
systemd-analyze calendar EXPRESSION...
systemd-analyze security [UNIT...]
systemd-analyze plot > boot.svg
Subcommand Description
time (default) Time spent in firmware, bootloader, kernel, initrd and userspace, with the target reached.
blame Units sorted by how long each took to initialize, slowest first.
critical-chain [UNIT] The chain of units the boot (or the given unit) actually waited for, with start times (@) and durations (+).
verify FILE... Load unit files and report syntax errors, unknown directives and missing dependencies without starting anything.
calendar EXPR Normalize a calendar expression and print the next time it elapses; add --iterations=N.
timespan EXPR Parse a time span such as 1h 30min into microseconds.
security [UNIT] Score the sandboxing settings of a service from 0.0 (safe) to 10.0 (unsafe).
plot Write an SVG timeline of the whole boot to stdout.
dot Emit the dependency graph in Graphviz format.
cat-config, unit-paths Show merged configuration files or the directories searched for units.

Returns: 0 on success. verify exits non-zero and prints a message per problem; calendar exits non-zero on a parse error.

Errors and edge cases: on a system not booted with systemd it fails with "System has not been booted with systemd as init system". In containers time often reports "not available".

Usage notes

  • blame is misleading on its own. It reports each unit's own time, but units start in parallel; a slow unit that nothing waits for costs nothing. Use critical-chain to see what actually delayed the boot.
  • Waiting for the network (*-wait-online.service) is the usual surprise; disable it if no service needs network-online.target.
  • Run verify after every unit edit before daemon-reload; it catches typos like ExecStar= that would otherwise only appear in the log.
  • Test timers before deploying them: systemd-analyze calendar "Mon..Fri *-*-* 09:00" --iterations=3. See Timer units.
  • security is advice, not a verdict. A score of 9.6 for a plain service is normal; add options from Service sandboxing and re-run it.
  • Compare boots by saving systemd-analyze blame after a change and diffing with the earlier output: diff.
  • plot needs an SVG viewer; the output is a standalone file you can open in any browser.
  • First boot after install includes one-off work and is not representative; measure the second or third.