Difference between revisions of "Limit the size of .log files & the journal"

imported>Handy
imported>Handy
(4 intermediate revisions by the same user not shown)
Line 41: Line 41:
After a reboot, you should find that your journal is now somewhat less than 50MB (or whatever limit you set), as it needs to have some working space. Mine went to 38M from 391M.
After a reboot, you should find that your journal is now somewhat less than 50MB (or whatever limit you set), as it needs to have some working space. Mine went to 38M from 391M.


See the troubleshooting section if the above did not work for you.
<br clear="all"/>


<br clear="all"/>
== The Journalctl command - a quick reference [http://www.freedesktop.org/software/systemd/man/journalctl.html]==
== The Journalctl command - a quick reference [http://www.freedesktop.org/software/systemd/man/journalctl.html]==


=== Add user to adm group, gives <user> full use of the journalctl command: ===
Note: Add user to adm group, gives <user> full use
of the journalctl command, so you don't need to use sudo
(swap "handy" for your username):
# usermod -a -G adm handy
 
Note2: You can pipe the output of journalctl to a file or
to a text display tool like "More" or "Less", as follows:
 
$ journalctl -b -p err|less
This gives you a means of avoiding the truncation of output
which some system' displays may experience.
I use a ~/.bashrc alias to make this easy:
alias errors="journalctl -b -p err|less"
When I type "errors" in the Terminal, all errors or worse,
since the last boot are displayed in the Terminal text
display tool "Less" & no lines are truncated.
Type Q to close "less".


# usermod -a -G adm handy


===== Access to full journal containing info from the system & users: =====
===== Access to full journal containing info from the system & users: =====
Line 67: Line 86:


  $ journalctl -b -p err
  $ journalctl -b -p err
Following is the above command with its output sent to a file called '''-ERRORS''' in your ''/home/<user>'' directory. Having the '''-''' at the beginning of the name should cause the file to be shown at the top of the list of files when viewing the contents of your '''~/''' (''/home/<user>'') directory. This command makes it easy to copy the contents of the -ERRORS file, & then paste it to the forum. Doing so allows us to display ALL of the command's output instead of only being able to cut & paste the truncated lines from our terminal:
$ Journalctl -b -p err > -ERRORS


== Filtering based on time: ==
== Filtering based on time: ==
Line 106: Line 129:
The Systemd Journal is capable of advanced functions beyond what has been mentioned here. The above is very good food for thought for people that are wondering if they need to be running '''syslog-ng''' or the like that creates most of the '''/var/log/*log''' files on their systems.
The Systemd Journal is capable of advanced functions beyond what has been mentioned here. The above is very good food for thought for people that are wondering if they need to be running '''syslog-ng''' or the like that creates most of the '''/var/log/*log''' files on their systems.


By experimenting with the above commands one can make an informed decision for themselves, though as mentioned at the beginning of the Journal section, Arch & therefore Manjaro still run both the new systemd journal & the old style log file system in parallel. So if you find the /var/log/*log files to be redundant & you want to be rid of them, various methods would be effective. I'm currently using /etc/cron.hourly & a script in the /etc/logrotate.d directory. I'll write further on this later.
By experimenting with the above commands one can make an informed decision for themselves, though as mentioned at the beginning of the Journal section, Arch & therefore Manjaro still run both the new systemd journal & the old style log file system in parallel. So if you find the /var/log/*log files to be redundant & you want to be rid of them, various methods would be effective.
 
Currently I'm running my system with syslog-ng (& its dependency) deleted. I deleted all of the log files from the /var/log directory (leaving any that are in their own sub-directories), except for Xorg.0.log , Xorg.0.old , lastlog , btmp & wtmp (pacman.log turned up when pacman was used). The deleted log files came back on reboot, but having since deleted them again they have stayed deleted for multiple reboots.


= Managing /var/log/* files =
= Managing /var/log/* files =
Anonymous user