linux之journalctl命令

journalctl命令 – 查看指定的日志信息
语法格式: journalctl [参数]
查看系统中全部的日志信息:
[root@os-client ~]# journalctl 
-- Logs begin at Fri 2023-07-21 14:16:22 CST, end at Sat 2023-07-29 17:25:46 CST. --
Jul 21 14:16:22 localhost.localdomain systemd-journal[95]: Runtime journal is using 8.0M (max al
Jul 21 14:16:22 localhost.localdomain kernel: Initializing cgroup subsys cpuset
Jul 21 14:16:22 localhost.localdomain kernel: Initializing cgroup subsys cpu
Jul 21 14:16:22 localhost.localdomain kernel: Initializing cgroup subsys cpuacct
Jul 21 14:16:22 localhost.localdomain kernel: Linux version 3.10.0-1160.90.1.el7.x86_64 (mockbui
Jul 21 14:16:22 localhost.localdomain kernel: Command line: BOOT_IMAGE=/boot/vmlinuz-3.10.0-1160
Jul 21 14:16:22 localhost.localdomain kernel: e820: BIOS-provided physical RAM map:

指定查看内核日志信息
[root@os-client ~]# journalctl 
-- Logs begin at Fri 2023-07-21 14:16:22 CST, end at Sat 2023-07-29 17:25:46 CST. --
Jul 21 14:16:22 localhost.localdomain systemd-journal[95]: Runtime journal is using 8.0M (max al
Jul 21 14:16:22 localhost.localdomain kernel: Initializing cgroup subsys cpuset
Jul 21 14:16:22 localhost.localdomain kernel: Initializing cgroup subsys cpu
Jul 21 14:16:22 localhost.localdomain kernel: Initializing cgroup subsys cpuacct
Jul 21 14:16:22 localhost.localdomain kernel: Linux version 3.10.0-1160.90.1.el7.x86_64 (mockbui
Jul 21 14:16:22 localhost.localdomain kernel: Command line: BOOT_IMAGE=/boot/vmlinuz-3.10.0-1160
Jul 21 14:16:22 localhost.localdomain kernel: e820: BIOS-provided physical RAM map:
指定查看本次系统启动的日志信息
[root@os-server ~]# journalctl -b
-- Logs begin at Thu 2023-07-20 14:35:42 CST, end at Sat 2023-07-29 17:30:46 CST. --
Jul 20 14:35:42 localhost.localdomain systemd-journal[88]: Runtime journal is using 8.0M (max al
Jul 20 14:35:42 localhost.localdomain kernel: Initializing cgroup subsys cpuset
Jul 20 14:35:42 localhost.localdomain kernel: Initializing cgroup subsys cpu
Jul 20 14:35:42 localhost.localdomain kernel: Initializing cgroup subsys cpuacct
Jul 20 14:35:42 localhost.localdomain kernel: Linux version 3.10.0-1160.90.1.el7.x86_64 (mockbui
Jul 20 14:35:42 localhost.localdomain kernel: Command line: BOOT_IMAGE=/boot/vmlinuz-3.10.0-1160
Jul 20 14:35:42 localhost.localdomain kernel: e820: BIOS-provided physical RAM map:
指定查看mariadb的日志信息
[root@os-client ~]# journalctl -u mariadb
-- Logs begin at Sat 2023-07-29 17:31:13 CST, end at Sat 2023-07-29 17:38:03 CST. --
Jul 29 17:38:00 os-client systemd[1]: Starting MariaDB database server...
Jul 29 17:38:00 os-client mariadb-prepare-db-dir[1487]: Initializing MariaDB database
Jul 29 17:38:01 os-client mariadb-prepare-db-dir[1487]: 230729 17:38:01 [Note] /usr/libexec/mysq
Jul 29 17:38:01 os-client mariadb-prepare-db-dir[1487]: 230729 17:38:01 [Note] /usr/libexec/mysq
Jul 29 17:38:01 os-client mariadb-prepare-db-dir[1487]: PLEASE REMEMBER TO SET A PASSWORD FOR TH
Jul 29 17:38:01 os-client mariadb-prepare-db-dir[1487]: To do so, start the server, then issue t
Jul 29 17:38:01 os-client mariadb-prepare-db-dir[1487]: '/usr/bin/mysqladmin' -u root password '
Jul 29 17:38:01 os-client mariadb-prepare-db-dir[1487]: '/usr/bin/mysqladmin' -u root -h os-clie
Jul 29 17:38:01 os-client mariadb-prepare-db-dir[1487]: Alternatively you can run:
指定查看最近10条日志信息
[root@os-client ~]# journalctl -n 3
-- Logs begin at Sat 2023-07-29 17:31:13 CST, end at Sat 2023-07-29 17:38:03 CST. --
Jul 29 17:38:01 os-client mysqld_safe[1570]: 230729 17:38:01 mysqld_safe Starting mysqld daemon 
Jul 29 17:38:03 os-client systemd[1]: Started MariaDB database server.
Jul 29 17:38:03 os-client polkitd[505]: Unregistered Authentication Agent for unix-process:1481:
[root@os-client ~]# 

持续追踪最新的日志信息,保持刷新内容:
[root@os-client ~]# journalctl -f
-- Logs begin at Sat 2023-07-29 17:31:13 CST. --
Jul 29 17:38:01 os-client mariadb-prepare-db-dir[1487]: Please report any problems at http://mariadb.org/jira
Jul 29 17:38:01 os-client mariadb-prepare-db-dir[1487]: The latest information about MariaDB is available at http://mariadb.org/.
Jul 29 17:38:01 os-client mariadb-prepare-db-dir[1487]: You can find additional information about the MySQL part at:
Jul 29 17:38:01 os-client mariadb-prepare-db-dir[1487]: http://dev.mysql.com
Jul 29 17:38:01 os-client mariadb-prepare-db-dir[1487]: Consider joining MariaDB's strong and vibrant community:
Jul 29 17:38:01 os-client mariadb-prepare-db-dir[1487]: https://mariadb.org/get-involved/
Jul 29 17:38:01 os-client mysqld_safe[1570]: 230729 17:38:01 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
Jul 29 17:38:01 os-client mysqld_safe[1570]: 230729 17:38:01 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Jul 29 17:38:03 os-client systemd[1]: Started MariaDB database server.
Jul 29 17:38:03 os-client polkitd[505]: Unregistered Authentication Agent for unix-process:1481:40803 (system bus name :1.12, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)
 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值