Information Technology Grimoire

Version .0.0.1

IT Notes from various projects because I forget, and hopefully they help you too.

logrotate

Assumptions

You have a file called /var/log/monitor.stats that you need to rotate

add log rotation

cp /etc/logrotate.d/ufw /etc/logrotate.d/monitorme
vim /etc/logrotate.d/monitorme

verify log rotation

logrotate /etc/logrotate.conf --debug
rotating pattern: /var/log/monitor.stats
 weekly (4 rotations)
empty log files are not rotated, old logs are removed
switching euid from 0 to 0 and egid from 0 to 4 (pid 941248)
considering log /var/log/monitor.stats
Creating new state
  Now: 2023-02-09 07:59
  Last rotated at 2023-02-09 07:00
  log does not need rotating (log has already been rotated)
switching euid from 0 to 0 and egid from 4 to 0 (pid 941248)