Linux command
journalctl 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Example
journalctl -b -p 3
Follow
journalctl -n 50 -f
Example
journalctl -u [unit]
Example
journalctl --since yesterday --until today
Example
journalctl _PID=[pid]
Grep
journalctl -g "[pattern]"
Delete
journalctl --vacuum-time=2d
Example
journalctl [path/to/executable]
说明
journalctl queries and displays messages from the systemd journal. The journal stores log data from the kernel, system services, and applications in a structured, indexed format.
参数
- -b, --boot
- Show messages from current boot (or specified boot)
- -p, --priority level
- Filter by priority (0=emerg to 7=debug, or names)
- -u, --unit unit
- Show messages from specified systemd unit
- -n, --lines n
- Show the most recent n lines
- -f, --follow
- Follow new messages as they appear
- -S, --since time
- Show entries after specified time
- -U, --until time
- Show entries before specified time
- -k, --dmesg
- Show kernel messages only
- -r, --reverse
- Reverse output (newest first)
- -o, --output format
- Output format (short, verbose, json, cat, etc.)
- --vacuum-time time
- Remove journal files older than time
- --vacuum-size size
- Reduce journal to specified size
- -g, --grep pattern
- Filter entries by regular expression (PCRE2)
- --no-pager
- Do not pipe output into a pager
- --list-boots
- Show a list of boot IDs with timestamps
- --disk-usage
- Show current disk usage of journal
- _PID=pid
- Filter by process ID
- _SYSTEMD_UNIT=unit
- Filter by systemd unit
FAQ
What is the journalctl command used for?
journalctl queries and displays messages from the systemd journal. The journal stores log data from the kernel, system services, and applications in a structured, indexed format.
How do I run a basic journalctl example?
Run `journalctl -b -p 3` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -b, --boot do in journalctl?
Show messages from current boot (or specified boot)