journalctl: The System Log Manager
journalctl | |
---|---|
Part Of | systemd |
Official Documentation | journalctl |
1 Description
The journalctl program is used to view or interact with log files or any information that systemd tracks and records. journalctl is included by default in basically all systemd installations.
2 Examples
2.1 View systemd Unit Output
In this example we use journalctl to view the output of a single systemd unit, in this case the systemd unit is ssh.service
.
user-1@vm:~$ sudo journalctl --unit=ssh.service
[sudo] password for user-1:
-- Boot 341b66530f9640a898e6b1307cbee828 --
May 26 18:08:19 vm systemd[1]: Starting ssh.service - OpenBSD Secure Shell server...
May 26 18:08:22 vm sshd[3185]: Server listening on 0.0.0.0 port 22.
May 26 18:08:22 vm sshd[3185]: Server listening on :: port 22.
May 26 18:08:22 vm systemd[1]: Started ssh.service - OpenBSD Secure Shell server.
Jun 01 01:29:06 vm systemd[1]: Stopping ssh.service - OpenBSD Secure Shell server...
Jun 01 01:29:06 vm sshd[3185]: Received signal 15; terminating.
Jun 01 01:29:06 vm systemd[1]: ssh.service: Deactivated successfully.
Jun 01 01:29:06 vm systemd[1]: Stopped ssh.service - OpenBSD Secure Shell server.
-- Boot 061e4d986aee446d91bfe051949be604 --
Jun 01 01:31:43 vm sshd[2726]: Server listening on 0.0.0.0 port 22.
Jun 01 01:31:43 vm sshd[2726]: Server listening on :: port 22.
Jun 01 01:31:43 vm systemd[1]: Starting ssh.service - OpenBSD Secure Shell server...
Jun 01 01:31:44 vm systemd[1]: Started ssh.service - OpenBSD Secure Shell server.
user-1@vm:~$
2.2 Displaying Boot Times
The example below demonstrates how to ouput a list of boot times for the current system.
user-1@vm:~$ sudo journalctl --list-boots
[sudo] password for user-1:
IDX BOOT ID FIRST ENTRY LAST ENTRY
-2 364a92b6d2104511818c32a4005c740b Sat 2024-08-31 10:41:25 PDT Sat 2024-09-07 07:25:01 PDT
-1 cc0e13a9303e46309fe884dc44282874 Sat 2024-09-07 09:32:36 PDT Wed 2024-09-11 23:35:01 PDT
0 bee268adf9644312b600313665bda448 Thu 2024-09-12 06:37:29 PDT Tue 2024-10-08 02:17:58 PDT
user-1@vm:~$
This document was last updated: