journalctl用法详解

journalctl用法详解文章目录一、journalctl命令简述二、journalctl常用选项一、journalctl命令简述journalctl[OPTIONS…][MATCHES…]Querythejournal.Flags:–systemShowthesystemjournal–userShowtheuserjournalforthecurrentuser-M–machine=CO

大家好,又见面了,我是你们的朋友全栈君。

一、journalctl命令简述

journalctl [OPTIONS...] [MATCHES...]

Query the journal.

Flags:
     --system              Show the system journal
     --user                Show the user journal for the current user
  -M --machine=CONTAINER   Operate on local container
  -S --since=DATE          Show entries not older than the specified date
  -U --until=DATE          Show entries not newer than the specified date
  -c --cursor=CURSOR       Show entries starting at the specified cursor
     --after-cursor=CURSOR Show entries after the specified cursor
     --show-cursor         Print the cursor after all the entries
  -b --boot[=ID]           Show current boot or the specified boot
     --list-boots          Show terse information about recorded boots
  -k --dmesg               Show kernel message log from the current boot
  -u --unit=UNIT           Show logs from the specified unit
  -t --identifier=STRING   Show entries with the specified syslog identifier
  -p --priority=RANGE      Show entries with the specified priority
  -e --pager-end           Immediately jump to the end in the pager
  -f --follow              Follow the journal
  -n --lines[=INTEGER]     Number of journal entries to show
     --no-tail             Show all lines, even in follow mode
  -r --reverse             Show the newest entries first
  -o --output=STRING       Change journal output mode (short, short-iso,
                                   short-precise, short-monotonic, verbose,
                                   export, json, json-pretty, json-sse, cat)
     --utc                 Express time in Coordinated Universal Time (UTC)
  -x --catalog             Add message explanations where available
     --no-full             Ellipsize fields
  -a --all                 Show all fields, including long and unprintable
  -q --quiet               Do not show privilege warning
     --no-pager            Do not pipe output into a pager
  -m --merge               Show entries from all available journals
  -D --directory=PATH      Show journal files from directory
     --file=PATH           Show journal file
     --root=ROOT           Operate on catalog files underneath the root ROOT
     --interval=TIME       Time interval for changing the FSS sealing key
     --verify-key=KEY      Specify FSS verification key
     --force               Override of the FSS key pair with --setup-keys

Commands:
  -h --help                Show this help text
     --version             Show package version
  -F --field=FIELD         List all values that a specified field takes
     --new-id128           Generate a new 128-bit ID
     --disk-usage          Show total disk usage of all journal files
     --vacuum-size=BYTES   Reduce disk usage below specified size
     --vacuum-time=TIME    Remove journal files older than specified date
     --flush               Flush all journal data from /run into /var
     --header              Show journal header information
     --list-catalog        Show all message IDs in the catalog
     --dump-catalog        Show entries in the message catalog
     --update-catalog      Update the message catalog database
     --setup-keys          Generate a new FSS key pair
     --verify              Verify journal file consistency

二、journalctl常用选项

  1. journalctl -e // Immediately jump to the end in the pager(立即跳到日志页面结尾处)
journalctl -e
1月 04 18:30:32 server1 systemd[1]: Started Session 22 of user root.
1月 04 18:30:32 server1 systemd[1]: Starting Session 22 of user root.
1月 04 18:30:32 server1 CROND[55734]: (root) CMD (/usr/lib64/sa/sa1 1 1)
1月 04 18:40:01 server1 systemd[1]: Started Session 23 of user root.
1月 04 18:40:01 server1 systemd[1]: Starting Session 23 of user root.
1月 04 18:40:01 server1 CROND[55818]: (root) CMD (/usr/lib64/sa/sa1 1 1)
1月 04 18:50:01 server1 systemd[1]: Started Session 24 of user root.
1月 04 18:50:01 server1 systemd[1]: Starting Session 24 of user root.
1月 04 18:50:01 server1 CROND[55907]: (root) CMD (/usr/lib64/sa/sa1 1 1)
1月 04 19:00:01 server1 systemd[1]: Started Session 25 of user root.
1月 04 19:00:01 server1 systemd[1]: Starting Session 25 of user root.
1月 04 19:00:01 server1 CROND[55997]: (root) CMD (/usr/lib64/sa/sa1 1 1)
1月 04 19:01:01 server1 systemd[1]: Started Session 26 of user root.
1月 04 19:01:01 server1 systemd[1]: Starting Session 26 of user root.
1月 04 19:01:01 server1 CROND[56011]: (root) CMD (run-parts /etc/cron.hourly)
1月 04 19:01:01 server1 run-parts(/etc/cron.hourly)[56014]: starting 0anacron
1月 04 19:01:01 server1 run-parts(/etc/cron.hourly)[56020]: finished 0anacron
1月 04 19:10:01 server1 systemd[1]: Started Session 27 of user root.
1月 04 19:10:01 server1 systemd[1]: Starting Session 27 of user root.
1月 04 19:10:01 server1 CROND[56105]: (root) CMD (/usr/lib64/sa/sa1 1 1)
  1. journalctl -u //查看指定单元 ( unit ) 的日志
journalctl -u httpd
[root@server1 ~]# journalctl -u httpd
-- Logs begin at 日 2020-11-22 04:33:29 CST, end at 一 2021-01-04 19:30:01 CST. --
1月 04 19:24:46 server1 systemd[1]: Starting The Apache HTTP Server...
1月 04 19:25:06 server1 httpd[56288]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::4f00:5a8e:3923:429d. Set the 'ServerName' directive 
1月 04 19:25:26 server1 systemd[1]: Started The Apache HTTP Server.
1月 04 19:27:57 server1 systemd[1]: Stopping The Apache HTTP Server...
1月 04 19:27:58 server1 systemd[1]: Stopped The Apache HTTP Server.
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/142159.html原文链接:https://javaforall.net

赞 (0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • navicate 15激活码_在线激活

    (navicate 15激活码)2021最新分享一个能用的的激活码出来,希望能帮到需要激活的朋友。目前这个是能用的,但是用的人多了之后也会失效,会不定时更新的,大家持续关注此网站~IntelliJ2021最新激活注册码,破解教程可免费永久激活,亲测有效,下面是详细链接哦~https://javaforall.net/100143.html…

    2022年3月27日
  • StrictMode使用详解

    StrictMode使用详解StrictMode    StrictMode最常用来捕捉应用程序的主线程,它将报告与线程及虚拟机相关的策略违例。一旦检测到策略违例(policyviolation),你将获得警告,其包含了一个栈trace显示你的应用在何处发生违例。除了主线程,我们还可以在Handler,AsyncTask,AsyncQueryHandler,IntentService等API中使用StrictMod

    2022年6月9日
  • SQL基础语句汇总[通俗易懂]

    SQL基础语句汇总[通俗易懂]引言语法基础连接数据库查看数据库使用数据库查看表查看表结构建表修改表添加字段移除字段变更字段插入全字段插入个别字段插入普通查询单表全字段查询单表个别字段查询多表查询条件查询单表条件查询多表条件查询嵌套查询并查询交查询删除更新常用函数求和求平均值计数求最大值求最小值常用的修饰符distinct字段中值唯一limit查询结果数限制

    2022年5月2日
  • leetcode-14最长公共前缀(分治|二分)[通俗易懂]

    leetcode-14最长公共前缀(分治|二分)[通俗易懂]原题链接编写一个函数来查找字符串数组中的最长公共前缀。如果不存在公共前缀,返回空字符串 “”。示例 1:输入:strs = [“flower”,”flow”,”flight”]输出:”fl”示例 2:输入:strs = [“dog”,”racecar”,”car”]输出:””解释:输入不存在公共前缀。 提示:0 <= strs.length <= 2000 <= strs[i].length <= 200strs[i] 仅由小写英文字母组成题解分

    2022年8月9日
  • CMD进入mysql及mysql字符集设置

    CMD进入mysql及mysql字符集设置1.开始-运行-cmd-回车 或者windows+r,进入电脑或者服务器的cmd,2.执行netstartmysql,启动mysql服务(netstopmysql为停止服务),3.1找到自己mysql安装目录的bin目录(我的是C:\ProgramFiles(x86)\MySQL\MySQLServer5.1\bin),操作顺序如下图 3.2在路径栏输入cmd,     …

    2022年5月20日
  • java有序map[通俗易懂]

    java有序map[通俗易懂]我们知道TreeMap的key是有顺序的,是自然顺序,也可以指定比较函数。但TreeMap默认不是按插入的顺序。为了让Map按照插入顺序显示,可以使用LinkedHashMap吧。它内部有一个链表,保持插入的顺序。迭代的时候,也是按照插入顺序迭代,而且迭代比HashMap快。转载于:https://www.cnblogs.com/lixiaoran/p/6780898.html…

    2022年9月24日

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号