journalctl命令 - 查看指定的日志信息
2024-01-09 本站作者 【 字体:大 中 小 】
journalctl命令来自英文词组“journal control”的缩写,其功能是用于查看指定的日志信息。
journalctl命令来自英文词组“journal control”的缩写,其功能是用于查看指定的日志信息。在RHEL7/CentOS7及以后版本的Linux系统中,Systemd服务统一管理了所有服务的启动日志,带来的好处就是可以只用journalctl一个命令,查看到全部的日志信息了。
语法格式:journalctl [参数] [对象]
常用参数:
-a | 显示所有字段信息 |
-b | 显示本次系统启动x日志 |
-c | 从指定位置开始显示条目 |
-D | 设置目录路径 |
-f | 追踪日志内容 |
-k | 显示内核日志 |
-m | 显示所有可用日志 |
-n | 设置日志条数 |
-o | 设置日志条目格式 |
-p | 依据优先级筛选 |
-q | 静默执行模式 |
-r | 反选内容后再显示 |
-u | 显示指定服务的日志 |
--help | 显示帮助信息 |
--version | 显示版本信息 |
参考示例
查看系统中全部的日志信息:
[root@linuxcool ~]# journalctl -- Logs begin at Thu 2023-05-18 02:12:18 CST, end at Sat 2023-05-28 13:15:02 CS> May 18 02:12:18 linuxprobe.com kernel: Linux version 4.18.0-80.el8.x86_64 (mock> May 18 02:12:18 linuxprobe.com kernel: Command line: BOOT_IMAGE=(hd0,msdos1)/vm> May 18 02:12:18 linuxprobe.com kernel: Disabled fast string operations ………………省略部分输出信息………………
指定查看内核日志信息:
[root@linuxcool ~]# journalctl -k -- Logs begin at Thu 2023-05-18 02:12:18 CST, end at Sat 2023-05-28 13:15:02 CS> May 18 02:12:18 linuxprobe.com kernel: Linux version 4.18.0-80.el8.x86_64 (mock> May 18 02:12:18 linuxprobe.com kernel: Command line: BOOT_IMAGE=(hd0,msdos1)/vm> May 18 02:12:18 linuxprobe.com kernel: Disabled fast string operations ………………省略部分输出信息………………
指定查看本次系统启动的日志信息:
[root@linuxcool ~]# journalctl -b -- Logs begin at Thu 2023-05-18 02:12:18 CST, end at Sat 2023-05-28 13:15:02 CS> May 18 02:12:18 linuxprobe.com kernel: x86/fpu: Supporting XSAVE feature 0x001:> May 18 02:12:18 linuxprobe.com kernel: x86/fpu: Supporting XSAVE feature 0x002:> May 18 02:12:18 linuxprobe.com kernel: x86/fpu: Supporting XSAVE feature 0x004:> ………………省略部分输出信息………………
指定查看某个服务程序的日志信息:
[root@linuxcool ~]# journalctl -u sshd -- Logs begin at Thu 2023-05-18 02:12:18 CST, end at Sat 2023-05-28 13:17:01 CS> May 18 02:12:22 linuxcool.com systemd[1]: Starting OpenSSH server daemon... May 18 02:12:22 linuxcool.com sshd[1109]: Server listening on 0.0.0.0 port 22. May 18 02:12:22 linuxcool.com sshd[1109]: Server listening on :: port 22. May 18 02:12:22 linuxcool.com systemd[1]: Started OpenSSH server daemon. ………………省略部分输出信息………………
指定查看最近10条日志信息:
[root@linuxcool ~]# journalctl -n 10 -- Logs begin at Thu 2023-05-18 02:12:18 CST, end at Sat 2023-05-28 13:17:01 CS> May 28 13:01:01 linuxcool.com run-parts[3541]: (/etc/cron.hourly) finished 0ana> May 28 13:15:00 linuxcool.com dbus-daemon[980]: [system] Activating via systemd> May 28 13:15:00 linuxcool.com systemd[1]: Starting Fingerprint Authentication D> May 28 13:15:00 linuxcool.com dbus-daemon[980]: [system] Successfully activated> May 28 13:15:00 linuxcool.com systemd[1]: Started Fingerprint Authentication Da> May 28 13:15:02 linuxcool.com gdm-password][3666]: gkr-pam: unlocked login keyr> May 28 13:15:02 linuxcool.com NetworkManager[1093]: <info> [1653714902.2810] a> May 28 13:17:01 linuxcool.com anacron[2921]: Job `cron.monthly' started May 28 13:17:01 linuxcool.com anacron[2921]: Job `cron.monthly' terminated May 28 13:17:01 linuxcool.com anacron[2921]: Normal exit (3 jobs run)
持续追踪最新的日志信息,保持刷新内容:
[root@linuxcool ~]# journalctl -f -- Logs begin at Thu 2023-05-18 02:12:18 CST. -- May 28 13:01:01 linuxcool.com run-parts[3541]: (/etc/cron.hourly) finished 0anacron May 28 13:15:00 linuxcool.com dbus-daemon[980]: [system] Activating via systemd: service name='net.reactivated.Fprint' unit='fprintd.service' requested by ':1.177' (uid=0 pid=2222 comm="/usr/bin/gnome-shell " label="unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023") May 28 13:15:00 linuxcool.com systemd[1]: Starting Fingerprint Authentication Daemon... May 28 13:15:00 linuxcool.com dbus-daemon[980]: [system] Successfully activated service 'net.reactivated.Fprint' May 28 13:15:00 linuxcool.com systemd[1]: Started Fingerprint Authentication Daemon. May 28 13:15:02 linuxcool.com gdm-password][3666]: gkr-pam: unlocked login keyring May 28 13:15:02 linuxcool.com NetworkManager[1093]: <info> [1653714902.2810] agent-manager: req[0x7fdcc8007190, :1.177/org.gnome.Shell.NetworkAgent/0]: agent registered May 28 13:17:01 linuxcool.com anacron[2921]: Job `cron.monthly' started May 28 13:17:01 linuxcool.com anacron[2921]: Job `cron.monthly' terminated May 28 13:17:01 linuxcool.com anacron[2921]: Normal exit (3 jobs run) ………………省略部分输出信息………………
与该功能相关的Linux命令:
- size命令 – 显示文件各段大小
- apt-get命令 – 管理服务软件
- rpmlint命令 – 检查rpm软件包中的常见错误
- update-alternatives命令 – 维护系统命令链接符
- ip6tables命令 – IPv6防火墙策略管理工具
- compgen命令 – 列出所有Linux命令
- chrt命令 – 实时管理进程的优先级策略
- zenity命令 – 显示图形框
- watch命令 – 周期性执行任务命令
- restorecon命令 – 恢复文件安全上下文
猜你喜欢
相关推荐
华为哪款手机玩游戏性能最好
随着手机游戏的日益普及,智能手机的性能对于玩家来说变得尤为重要。作为领先的智能手...
扩音器什么品牌音质最好(哪个品牌的扩音器音质最佳?)
在音响领域,扬声器作为一种重要的扩音设备,广泛应用于演讲、演出、会议等场合。市场...
铠侠固态硬盘怎么样(铠侠固态硬盘的表现如何?)
固态硬盘作为一种计算机存储设备,近年来因其在性能和速度上的突破而受到广泛关注。作...
公认最静音的电风扇(国内10大电风扇品牌排行)
本文将对国内10大电风扇品牌进行排名,并深入分析各品牌的产品优势。公认最安静的电...
光信号闪红灯会自己好吗(路由器闪红灯是怎么回事)
路由器断网是一件很头疼的事情。路由器闪烁红灯,无法连接到网络。路由器上闪烁的红灯...
联想k29为什么是神机(联想k29怎么样)
在现代科技发展的浪潮中,智能手机已经成为人们生活的必需品。在众多手机品牌中,联想...
国内冰箱排名前十的品牌(质量最好的10大冰箱品牌)
中国冰箱行业是全球最大的冰箱生产和消费市场之一。今天小编介绍2023年中国十大冰...
凯夫拉手机壳怎么样(凯夫拉手机壳的表现如何?)
手机已经成为我们日常生活中不可或缺的一部分,因此保护手机免受损害成为一项重要的任...
键盘突然没反应是怎么回事
随着现代科学技术的飞速发展,计算机已经成为我们生活中不可缺少的一部分。但是在电脑...
垃圾处理器有必要买吗(垃圾处理器值得买吗)
现代社会,科技的不断进步,消费方式的改变,让我们面临越来越多的选择。作为一种新型...