systemd-analyze — boot and service analysis
💬 "systemd-analyze command"
systemd-analyze is a tool for boot and service analysis that analyzes and visualizes systemd boot time and service startup order/dependencies.
It measures boot time (firmware→userspace). It provides a ranking (blame) of startup time per service.
- Concept: Measures boot time (firmware→userspace).
- Key Features: Provides a ranking (blame) of startup time per service.
- Advantages: Visualizes dependency graphs as SVG.
- Usage: Tracks bottlenecks with critical-chain.
Installation and Download
systemd-analyze is installed via a package manager or an official script.
| Environment | Command |
|---|---|
| Built-in with systemd | systemd-analyze |
| Check boot time | systemd-analyze |
| Service ranking | systemd-analyze blame |
| Generate graph | systemd-analyze plot > boot.svg |
| Verify | systemd-analyze --version |
Verify the installation with systemd-analyze --version.
Frequently Used Options
| Option | Description |
|---|---|
| systemd-analyze | Total boot time |
| systemd-analyze blame | Startup time ranking per service |
| systemd-analyze critical-chain | Dependency bottleneck chain |
| systemd-analyze plot > boot.svg | Boot visualization SVG |
| systemd-analyze time | kernel→init→userspace breakdown |
3 Essential Command Combinations
systemd-analyze critical-chain— Track the slowest dependency chainsystemd-analyze blame | head -10— Top 10 slowest servicessystemd-analyze plot > boot.svg— Full visualization
💬 "Show me an example of using systemd-analyze on a real server"
Here is a step-by-step guide to situations you frequently encounter on a production server.
Step 1: Check Boot Time
Check the total boot time.
systemd-analyze
Step 2: Slow Services
Identify the top 5 slowest services.
systemd-analyze blame | head -5
Step 3: Track Bottlenecks
Track dependency bottlenecks.
systemd-analyze critical-chain
Actual Execution Screen
This is the result of checking boot time and blame using systemd-analyze.
!systemd-analyze command execution result
Production server in operation
How It's Used in Practice
1. Tracking Boot Bottlenecks
Situation — You need to find the cause of slow boot.
systemd-analyze critical-chain
Result — You can see that NetworkManager-wait-online is consuming 1.4 seconds.
Key Point — Following the dependency chain reveals the bottleneck service.
2. Checking Service Ranking
Situation — You want to identify the slowest service.
systemd-analyze blame | head -5
Result — Services are slow in the order: nginx, postgresql, docker.
Key Point — The blame time only measures the service's execution time.
Actual Execution Screen
This is the result of tracking bottlenecks using systemd-analyze critical-chain.
!systemd-analyze command execution result 2
Production server in operation
Points to Note
- The plot command generates an SVG file. On a server, you can download it using scp to view it.
- The blame time only measures the service's execution time. Check dependency waiting time with critical-chain.
- Boot time varies depending on hardware and instance type. Compare within the same instance type.
Source (HTML): https://games.aidebatehub.com/programs/linux/services/systemd-analyze.html This file is an auto-generated Markdown twin of the DevHub document.
AI Knowledge Hub
Visitor Comments