Skip to content
This repository was archived by the owner on Mar 10, 2024. It is now read-only.

Log rotate configuration

emcauliffe edited this page May 25, 2023 · 2 revisions

Log Rotation Configuration

Space is at a premium on the Jetson TX2. One way of reducing space wastage is by configuring the logrotate package. This will limit the amount of space that log files consume on the Jetson. Often log files can grow to sizes in excess of 1GB, so this is an important configuration step.

Installing logrotate package

The logrotate package should come installed by default. To confirm its presence, run

logrotate --version

If the package is not installed, it can be installed with the following command:

sudo apt install logrotate

Man page for Ubuntu 18.04 logrotate can be found here: https://manpages.ubuntu.com/manpages/bionic/man8/logrotate.8.html

Setting global parameters in logrotate.conf

To configure log behaviour open logrotate.conf

sudo nano logrotate.conf

You should make the following adjustments

  • Set logrotate to run daily. Replace weekly with daily

  • Uncomment the line #compress to enable log compression with gzip

  • Add maxsize 100M to the bottom of the file. This will rotate logs when they reach a size >=100 MB. Note that this will trigger even if the logrotate interval has not yet occurred (ie. it will run every time the log is too large, not just daily)

Setting parameters for kern.log and syslog

Open the logrotate conf file for syslog & kern.log

sudo nano /etc/logrotate.d/rsyslog

In the /var/log/syslog and /var/log/kern.log blocks, add a maxsize line to limit the log sizes

/var/log/syslog
{
    ...
    maxsize 100M
    ...
}

...
/var/log/kern.log
...
{
    ...
    maxsize 100M
    ...
}