Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set systemd journalctl to ignore process

Tags:

systemd

My journalctl is littered with gnome-session warnings. I've tracked down the issue to Google Chrome, and the warning is relatively harmless. However, it's flooded my journal output, and frankly I won't be able to find what I need if I do need to check it.

May 30 12:13:49 hostname gnome-session[1347]: Window manager warning: meta_window_activate called by a pager with a 0 timestamp; the pager needs to be fixed.

Frankly, it's a Chrome issue and I'll leave it at that. But is there a way to make the journalctl command suppress output from a certain process? I'd like to just disable gnome-session logging altogether.

like image 434
dook Avatar asked May 30 '14 19:05

dook


1 Answers

This question seems like it would be a better fit on Unix & Linux.

Regardless though, being able to filter out units when perusing logs can easily be done piping to grep -v even when following (with grep's --line-buffered param) like

journalctl -f | grep --line-buffered -v "gnome"

That still sucks because now there is no helpful coloring. Constructing the command arguments for journalctl gives a much nicer experience.

JARGS=`journalctl -F _COMM | sed -e 's/gnome.*//' -e 's/^/_COMM=/' | xargs`
journalctl -a -f $JARGS

Now follow works as nicely as paging while hiding gnome lines in less using $!gnome. Woot!

It is a shame systemctl and journalctl don't allow regex matching for inclusion/exclusion.


On a personal use system (which I'm guessing your on because of the gnome-session annoyance) there are a few settings that may be useful to setup.

Edit the system journald.conf to

  1. Split the log by boot.
    verify Storage= persist or auto (default).
    and create sudo mkdir -p /var/log/journal
  2. Limit storage use by time.
    MaxRetentionSec=1week

Reboot to effectively restart the systemd-journald.service.

Then you can use

journalctl -a -b -f $JARGS # -b to limit to current boot 

or whatever args you desire without the unwanted gnome-session stuff.

like image 177
Thell Avatar answered Oct 19 '22 16:10

Thell