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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • [飞控]如何学习无人机-入门篇「建议收藏」

    学什么我把无人机分成3个大模块操作目的:组装无人机,享受驾驶无人机的乐趣。抱歉我给不了太多建议,因为我从没有以此为目进行过学习,但是我知道这一部分的知识关键词是【航模】,有非常多的【航模】发烧友可以给你更专业的意见。知识目的:了解无人机的本质知识解决的是「why?」如果你遇到的问题通常是,为什么要用欧拉角?为什么要用滤波?那说明你现在需要的问题都是知识型问题。关键词是【导航】【控制…

    2022年4月15日
    182
  • java script 下载_JavaScript下载[通俗易懂]

    java script 下载_JavaScript下载[通俗易懂]JavascriptPlus是一个小巧的Javascript脚本辅助编程工具,主要方便开发者对js代码进行测试、预览以及运行等操作,特点包括用不同的颜色显示语法和关键词,有稍许的程序输入预测功能,测试运行子程序等等。JavascriptPlus是一款功能强劲的javascript文本编辑器。内置的智能系统能够提示你-各种Javascript物件、性质和触发事件,-各种Html和Shee…

    2022年6月14日
    22
  • 数据结构知识整理

    数据结构知识整理基于严蔚敏及吴伟民编著的清华大学 C 语言版教材并结合网上相关资料整理 http www docin com p 2027739005 html 第一章 绪论 1 数据结构 是一门研究非数值计算的程序设计问题中计算机的操作对象以及他们之间的关系和操作等的学科 2 数据结构涵盖的内容 3 基本概念和术语 数据 对客观事物的符号表示 在计算机科学中是指所有能输入到计算机中并被计算

    2025年7月3日
    0
  • 暴力破解加密压缩文件

    暴力破解加密压缩文件实验目的应用Python程序设计语言的相关知识,对加密的压缩文件进行破解。实验所用仪器(或实验环境)Python3.8实验基本原理及步骤(或方案设计及理论计算)任务1:定义一个函数,函数带有一个参数L(类型为整数),函数返回一个长度为L、包含大小写字母和数字的随机密码(类型为字符串)。在任务1中,可以借助random中的choice,以及string库中的ascii_letters;至少用3个不同的长度测试函数的返回值。ascii_letters基本上是ascii_lowercase和

    2022年6月3日
    40
  • layoutSubviews总结

    layoutSubviews总结ioslayout机制相关方法-(CGSize)sizeThatFits:(CGSize)size-(void)sizeToFit——————–(void)layoutSubviews-(

    2022年7月1日
    22
  • web服务器双机热备方案解析「建议收藏」

    (1)、假设外网虚拟IP72.249.146.214上,内网hosts设置db10对应内网虚拟IP192.168.146.214  (2)、默认情况下,由主机绑定内、外网虚拟IP,备机作为备份,当主机的MySQL、Nginx或服务器出现故障无法访问时,备机会自动接管内、外网虚拟IP。两台服务器都启动负责监控、自动切换虚拟IP的守护进程/usr/bin/nohup/bi

    2022年4月7日
    84

发表回复

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

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