Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the journalctl command under Linux

2025-03-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report