Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use the journalctl command under Linux

Shulou Source: shulou.com Published: 2022-06-01 21:02:05 10月16日 Update

This article mainly shows you "how to use journalctl commands under Linux". The content is simple and clear. I hope it can help you solve your doubts. Let me lead you to study and learn this article "how to use journalctl commands under Linux".

Log management tool journalctl is a proprietary log management tool on centos7, which reads information from the file message. Systemd uniformly manages startup logs for all Unit.

Use method $man journalctl

$journalctl-help

Common methods

$journalctl

When there is no option, all log records are output by default

$journalctl-n [num]

Displays the log of the last num line. If num is omitted, the last 10 lines are displayed by default

$journalctl-f

Scrolling the latest log in real time

$journalctl-u

Displays the logs of the specified unit. Unit_name is a specific unit name. If you want to merge and display multiple unit logs, you can use multiple-u

$journalctl-o

Set the format of log output. The value of mode is (short, short-iso,short-precise, short-monotonic, verbose,export, json, json-pretty, json-sse, ca).

$journalctl-no-pager

Log default paging output,-no-pager changed to normal standard output

$journalctl-since

Display data from a certain point in time

Journalctl-since= "2020-08-31 10:00:00" # shows data after 10:00 on 31 August 2020

Journalctl-since "10 min ago" # displays logs for the last 10 minutes

Journalctl-since today/yesterday # shows logs since today / yesterday

Journalctl-since "2020-08-31 10:00:00"-until "2020-08-31 11:00:00" # shows logs for a certain period of time (2020-08-31 10:00-11:00)

# until can also be used as follows:

-until "1 hour ago"

-until now

$journalctl-k

View the system kernel log

Match

$journalctl-o json-n 1

You can see the json output format of the latest log. We can match the corresponding log according to the key and value of json.

$journalctl _ PID=28655

Gets the log of the specified process

$journalctl _ UID=33-since=today

View the log of the specified user today

$journalctl _ SYSTEMD_UNIT=cron.service PRIORITY=6

Matching through system unit and priority

View logs with a specified priority (and above)

There are 8 levels of log priority.

0: emerg

1: alert

2: crit

3: err

4: warning

5: notice

6: info

7: debug

The above is all the contents of this article entitled "how to use journalctl commands under Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Logs outputs commands priorities content tools articles management multiple data methods time formats management tools systems learning help usage information kernel Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info MariaDB Shulou Technology Huawei Microsoft