Difference between revisions of "Limit the size of .log files & the journal"
Views
Actions
Namespaces
Variants
Tools
Limit the size of .log files & the journal (view source)
Revision as of 23:56, 17 February 2017
, 7 years ago→The journal & the logs duplicate the same information
imported>Handy |
imported>Handy |
||
Line 32: | Line 32: | ||
This topic will go into far more depth, covering the use of the '''logrotate''' command, '''logrotate.conf''', the '''/etc/cron.daily cron.weekly cron.monthly cron.yearly''', and some ways to run created scripts, plus a mention of the '''crontab''' method of running a script also. I'll try to make this section accessible to as many people as possible, which means this will be a long page. | This topic will go into far more depth, covering the use of the '''logrotate''' command, '''logrotate.conf''', the '''/etc/cron.daily cron.weekly cron.monthly cron.yearly''', and some ways to run created scripts, plus a mention of the '''crontab''' method of running a script also. I'll try to make this section accessible to as many people as possible, which means this will be a long page. | ||
<br clear="all"/> | |||
=Read this first its important= | |||
'''etc/systemd/journald.conf.d/*.conf''' overrides the file '''journald.conf''' | |||
'''man journald.conf''' | |||
When packages need to customize the configuration, they can install configuration snippets in | |||
/usr/lib/systemd/*.conf.d/. Files in /etc/ are reserved for the local administrator, who may use | |||
this logic to override the configuration files installed by vendor packages. The main configuration | |||
file is read before any of the configuration directories, and has the lowest precedence; entries in | |||
a file in any configuration directory override entries in the single configuration file. Files in | |||
the *.conf.d/ configuration subdirectories are sorted by their filename in lexicographic order, | |||
regardless of which of the subdirectories they reside in. If multiple files specify the same option, | |||
the entry in the file with the lexicographically latest name takes precedence. It is recommended to | |||
prefix all filenames in those subdirectories with a two-digit number and a dash, to simplify the | |||
ordering of the files. | |||
What that means is that you can create configuration files '''.conf''' in the following directory, with suitable names of your choice /etc/systemd/journald.conf.d/ that take precedence over any other settings or configurations in systemd. Please bear that in mind when you read the following? | |||
<br clear="all"/> | <br clear="all"/> | ||
Line 47: | Line 68: | ||
There is usually no need to interfere with the maximum size of the journal, as it has been built to monitor the amount of free space on the partition where it exists & will shrink itself by deleting the oldest entries when a shortage of space demands it. | There is usually no need to interfere with the maximum size of the journal, as it has been built to monitor the amount of free space on the partition where it exists & will shrink itself by deleting the oldest entries when a shortage of space demands it. | ||
Use your | Use your favorite text editor with root privileges, (starting it with '''sudo''' will do the job). | ||
Note: the name '''size'''.conf is user created. | |||
With your text editor create a file called '''size.conf''' in the following location '''/etc/systemd/journald.conf.d/size.conf''' The following sets the maximum file size to a 50 MB limit for the '''/var/log/journal''' . | |||
[Journal] | [Journal] | ||
Line 57: | Line 78: | ||
SystemMaxFileSize=50M | SystemMaxFileSize=50M | ||
You can also | You can also limit the content of the journal by specifying the level of the data to be added to the journal. This is done by creating & editing the file '''/etc/systemd/journald.conf.d/level.conf''' | ||
Note: the name '''level'''.conf is user created. | |||
[Journal] | [Journal] |