Check logs using journalctl

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]
jour­nalctl _UID=[user id]
journalctl _PID=[process id]

By priority

journalctl -p err..alert
codepriority
0emerg
1alert
2crit
3err
4warn­ing
5notice
6info
7debug

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 --vacu­um-­siz­e=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

Share This

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*
*