journalctl
Jan. 22, 2023, 7:58 p.m.
List boots
journalctl --list-boots
Logs of a previous boot
journalctl -b -1
-b -1 means boot logs of -1 index of boot list
Errors since boot
sudo journalctl -p 3 -xb
-p 3
means priority err
-x provides extra message information
-b means since last boot
priorities
- 0: emerg
- 1: alert
- 2: crit
- 3: err
- 4: warning
- 5: notice
- 6: info
- 7: debug
Logs of spesific daemon from a previous time
- journalctl -u nginx.service -u php-fpm.service --since today
e.g.:
--since 09:00 --until "1 hour ago"
Display Kernel Logs
- journalctl -k
No Pager
- journalctl --no-pager
Tail Like
-n and -f works just like in tail
- journalctl -k
- journalctl --no-pager
Optimize
Get disk usage
- journalctl --disk-usage
Compress
- sudo journalctl --vacuum-size=1G
- sudo journalctl --vacuum-time=1years
Configure
- sudo mkdir -p /var/log/journal # if you planning to make it persistent to see previous bot logs
- sudo nano /etc/systemd/journald.conf
[Journal]
#Storage=auto # make persistent if you want to keep logs
#Compress=yes
#Seal=yes
#SplitMode=uid
#SyncIntervalSec=5m
#RateLimitIntervalSec=30s
#RateLimitBurst=10000
SystemMaxUse=100M # max size of logs
#SystemKeepFree=
#SystemMaxFileSize=
#SystemMaxFiles=100
#RuntimeMaxUse=
#RuntimeKeepFree=
#RuntimeMaxFileSize=
#RuntimeMaxFiles=100
#MaxRetentionSec=
#MaxFileSec=1month
#ForwardToSyslog=no
#ForwardToKMsg=no
#ForwardToConsole=no
#ForwardToWall=yes
#TTYPath=/dev/console
#MaxLevelStore=debug
#MaxLevelSyslog=debug
#MaxLevelKMsg=notice
#MaxLevelConsole=info
#MaxLevelWall=emerg
#LineMax=48K
#ReadKMsg=yes
#Audit=yes
#Storage=auto # make persistent if you want to keep logs
#Compress=yes
#Seal=yes
#SplitMode=uid
#SyncIntervalSec=5m
#RateLimitIntervalSec=30s
#RateLimitBurst=10000
SystemMaxUse=100M # max size of logs
#SystemKeepFree=
#SystemMaxFileSize=
#SystemMaxFiles=100
#RuntimeMaxUse=
#RuntimeKeepFree=
#RuntimeMaxFileSize=
#RuntimeMaxFiles=100
#MaxRetentionSec=
#MaxFileSec=1month
#ForwardToSyslog=no
#ForwardToKMsg=no
#ForwardToConsole=no
#ForwardToWall=yes
#TTYPath=/dev/console
#MaxLevelStore=debug
#MaxLevelSyslog=debug
#MaxLevelKMsg=notice
#MaxLevelConsole=info
#MaxLevelWall=emerg
#LineMax=48K
#ReadKMsg=yes
#Audit=yes