Using journalctl - The Ultimate Guide To Logging
Using journalctl - The Ultimate Guide To Logging
loggly.com
All Messages
$ journalctl
The entries will start with a banner similar to this which shows
the time span covered by the log.
1 de 9 23/3/23, 19:03
Using journalctl - The Ultimate Guide To Logging about:reader?url=https%3A%2F%2Ffanyv88.com%3A443%2Fhttps%2Fwww.loggly.co...
Long entries are printed to the width of the screen and truncated
off at the end if they don’t fit. The cut-off portion can be viewed
using the left and right arrow keys.
Boot Messages
$ journalctl -b
$ journalctl -b -1
$ journalctl --list-boots
2 de 9 23/3/23, 19:03
Using journalctl - The Ultimate Guide To Logging about:reader?url=https%3A%2F%2Ffanyv88.com%3A443%2Fhttps%2Fwww.loggly.co...
The first field is the offset (0 being the latest boot, -1 being the
boot before that, and so on), followed by a Boot ID (a long
hexadecimal number), followed by the time stamps of the first
and the last messages related to that boot.
Time Ranges
By Unit
3 de 9 23/3/23, 19:03
Using journalctl - The Ultimate Guide To Logging about:reader?url=https%3A%2F%2Ffanyv88.com%3A443%2Fhttps%2Fwww.loggly.co...
$ journalctl -u nginx.service
Follow or Tail
$ journalctl -f
$ journalctl -u mysql.service -f
Like the tail command, the -n switch will print the specified
number of most recent journal entries. In the command below,
we are printing the last 50 messages logged within the last hour.
$ journalctl -u sshd.service -r -n 1
4 de 9 23/3/23, 19:03
Using journalctl - The Ultimate Guide To Logging about:reader?url=https%3A%2F%2Ffanyv88.com%3A443%2Fhttps%2Fwww.loggly.co...
Output Formats
5 de 9 23/3/23, 19:03
Using journalctl - The Ultimate Guide To Logging about:reader?url=https%3A%2F%2Ffanyv88.com%3A443%2Fhttps%2Fwww.loggly.co...
"__CURSOR" : "s=c4ee459c883148549d114c566bc0b979;
i=12b782;b=6c92864cbcc64a5fabebe04147953894;
m=42d22604a2;t=58bc87981a1f5;x=8daf632187
"__REALTIME_TIMESTAMP" : "1561068031812085",
"__MONOTONIC_TIMESTAMP" : "286993548450",
"_BOOT_ID" : "6c92864cbcc64a5fabebe04147953894",
"SYSLOG_FACILITY" : "3",
"_UID" : "0",
"_GID" : "0",
...
"UNIT" : "apache2.service",
"CODE_LINE" : "2039",
"CODE_FUNCTION" : "unit_notify",
"_SOURCE_REALTIME_TIMESTAMP" : "1561068031809136"
6 de 9 23/3/23, 19:03
Using journalctl - The Ultimate Guide To Logging about:reader?url=https%3A%2F%2Ffanyv88.com%3A443%2Fhttps%2Fwww.loggly.co...
By Priority
$ journalctl -b -1 -p "emerg".."crit"
By User
To find all messages related to a particular user, use the UID for
that user. In the following example, we are finding the UID of the
user mysql.
$ id mysql
And then we are querying the journal for all messages logged by
that user.
# journalctl _UID=108
7 de 9 23/3/23, 19:03
Using journalctl - The Ultimate Guide To Logging about:reader?url=https%3A%2F%2Ffanyv88.com%3A443%2Fhttps%2Fwww.loggly.co...
8 de 9 23/3/23, 19:03
Using journalctl - The Ultimate Guide To Logging about:reader?url=https%3A%2F%2Ffanyv88.com%3A443%2Fhttps%2Fwww.loggly.co...
9 de 9 23/3/23, 19:03