Recently, I have setup a script that outputs to a single log file... After quite a while this file begins to become too large to manage. I was wondering what the easiest way is to setup log rotations for every few hundred lines located in the original log file?
Asked
Active
Viewed 6,007 times
1 Answers
6
You can use logrotate, execute this command to install it:
sudo apt-get install logrotate
Logrotate's configuration can generally be found in 2 places on Ubuntu (from Digital Ocean):
/etc/logrotate.conf: this file contains some default settings and sets up rotation for a few logs that are not owned by any system packages. It also uses an include statement to pull in configuration from any file in the/etc/logrotate.ddirectory./etc/logrotate.d/: this is where any packages you install that need help with log rotation will place their Logrotate configuration.
On a standard install you should already have files here for basic system tools like apt, dpkg, rsyslog and so on.
By default, logrotate.conf will configure weekly log rotations (weekly), with log files owned by the root user and the syslog group (su root syslog), with four log files being kept (rotate 4), and new empty log files being created after the current one is rotated (create).
If you want to learn more about how to use this tool, please visit the following link: How To Manage Logfiles with Logrotate on Ubuntu 16.04
Hope this helps.
galoget
- 3,023