Skip to content

Configuration to save ROS log only for one month. The oldest ones (more than 30 days) are automatically deleted.

Notifications You must be signed in to change notification settings

ndiazrey/logrotate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

logrotate

Crontab file

Crontab is a tool with which you can schedule tasks. You can modify the time how often you want a task to be executed by minutes, hours, days, months or years. In this case, the file has been configured to run logrotate every half hour. We must indicate the path where the logrotate that we are going to use is located. If we wanted to edit this file, we would only have to do the command:

crontab -e

Logrotate file

Inside the logrotate.d folder, the logrotate.conf file has been created. The logrotate file can be configured in many ways, with different parameters depending on what you want to do. In the following link you can consult the different parameters that can be used to configure the logrotate file.

In this case, the objective is to eliminate the log files older than one month, therefore the following parameters have been used.

  • maxsize 1k: This parameter indicates the maximum size that the file can have, in this case 1 kilobyte.
  • weekly: Rotates the log files every Sunday.
  • rotate 4: The log files will be changed 4 times before being removed.
  • nocompress: Older versions of the log files are not compressed.
  • notifempty: This indicates that the log file is not rotated if it is empty.
  • create: Right after the rotation, the new log file with the same name as the newly rotated one is created.

With these parameters the files will be rotated up to 4 times when they exceed the size 1k or a week has passed. Since the files are rotated every 7 days, 4 times maximum, there will be no files older than 28 days, except for those that are empty, which are not rotated.

Logrotate-state

This file is automatically created when logrotate is executed by cron. It keeps a record of when the last rotations of the different logs have been.

Logrotate.py

A python code has been created that generates the logrotate.conf file. In this code, you must indicate the logs on which you want to act. For this test, the logs from the rb_theron_relase package have been used. On the other hand, also in this code you have to indicate the logrotate.conf parameters.

About

Configuration to save ROS log only for one month. The oldest ones (more than 30 days) are automatically deleted.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages