受欢迎的博客标签

Ubuntu Journalctl :How To Use Journalctl to View and Manipulate Systemd Logs

Published

Basic Log Viewing

journalctl

output

-- Logs begin at Tue 2015-02-03 21:48:52 UTC, end at Tue 2015-02-03 22:29:38 UTC. --
Feb 03 21:48:52 localhost.localdomain systemd-journal[243]: Runtime journal is using 6.2M (max allowed 49.
Feb 03 21:48:52 localhost.localdomain systemd-journal[243]: Runtime journal is using 6.2M (max allowed 49.
Feb 03 21:48:52 localhost.localdomain systemd-journald[139]: Received SIGTERM from PID 1 (systemd).
Feb 03 21:48:52 localhost.localdomain kernel: audit: type=1404 audit(1423000132.274:2): enforcing=1 old_en
Feb 03 21:48:52 localhost.localdomain kernel: SELinux: 2048 avtab hash slots, 104131 rules.
Feb 03 21:48:52 localhost.localdomain kernel: SELinux: 2048 avtab hash slots, 104131 rules.
Feb 03 21:48:52 localhost.localdomain kernel: input: ImExPS/2 Generic Explorer Mouse as /devices/platform/
Feb 03 21:48:52 localhost.localdomain kernel: SELinux:  8 users, 102 roles, 4976 types, 294 bools, 1 sens,
Feb 03 21:48:52 localhost.localdomain kernel: SELinux:  83 classes, 104131 rules

Displaying Logs from the Current Boot

journalctl -b

 

Time

journalctl --since yesterday
journalctl --since 09:00 --until "1 hour ago"

journalctl --since "1 hour ago"

 

Filtering By Unit

journalctl -u nginx.service
sudo journalctl -fu nginx.service

 

//Ubuntu查看实时输出日志

sudo journalctl -fu kestrel-wwwstocksocom.service

//Ubuntu查看历史日志
sudo journalctl -u kestrel-wwwstocksocom.service

 

How To Use Journalctl to View and Manipulate Systemd Logs