1. Download Logrotate
Installation in Fedora and CentOS
Install logrotate crontabs
On Debian and Ubuntu
Install logrotate cron
2. Create a log file
cd/var/log/Touchfilefile. log
3. Create a File.log profile to add
vim/etc/logrotate.d/File
/vsr/log/file.log{
Monthly log files per month round daily daily weakly yealy
Rotate 5 Stores 5 archived logs, the longest automatic deletion for the sixth archive
Compress compressing with an archived file in gzip
Mail address sends dump log files to the specified e-mail addresses
Nocompress When compression is not required, use this parameter
Copytruncate for log files that are still open, to back up and truncate the current log
Nocopytruncate backing up log files but not truncation
Create 644 root root dump file, creating a new log file with the specified file mode
Size 20M Specifies that the file will be dumped when it reaches 20M on the same day
The above parameters can be added according to their needs
4. Manually start the Logrotate
LOGROTATE-VF /etc/logrotate.d/file
Log file Management Logrotate configuration