This tutorial will go over how to check logs using journalctl on linux.
Get all the logs for the current boot
The log entries are from all the services of current boot.
journalctl -b
current boot
journalctl -b -0
last boot
journalctl -b -1
from sometime ago
journalctl --since="20 min ago"
journalctl --since="1 hour ago"
by app, user id and process id
journalctl -u [unit name]
journalctl --user-unit [my-application]
journalctl _UID=[user id]
journalctl _PID=[process id]
By priority
journalctl -p err..alert
code | priority |
0 | emerg |
1 | alert |
2 | crit |
3 | err |
4 | warning |
5 | notice |
6 | info |
7 | debug |
get number of entries
journalctl -u [unit name] -n 10
get all logs without pager
journalctl --no-pager
journalctl --no-pager | less -S
show total log size
journalctl --disk-usage
clean logs to get disk space usage below 100 MB
journalctl --vacuum-size=100M
clear logs older than two weeks
journalctl –vacuum-time=2weeks
output format
journalctl -b -u [unit name] -o json
system config
/etc/systemd/journald.conf
add user access
usermod -a -G systemd-journal USER
Do you like the tutorial “Check logs using journalctl” ? If you want latest update and find more tips and tricks to build your own business platform, please checkout more articles on https://www.productdeploy.com and https://blog.productdeploy.com and subscribe the newsletter