Logrotate.
Function:
1. To reduce the disk space by removing old logs, depending upon the configuration file(/etc/logrotate.conf).
2. Systematic divion of logs without combining all logs in single file.
Features:
1. Possible to create seperate logrotae files in /etc/logrotate.d
Ex. To create logrotate for mail, create a file /etc/logrotate.d/mail and add the below entry.
/var/log/maillog {
rotate 1
daily
size 10k
missingok
rotate 52
compress
delaycompress
notifempty
create 640 root adm
sharedscripts
postrotate
/etc/init.d/postfix reload > /dev/null
endscript
}
To execute logrotate now, execute the command:
#logrotate /var/log/maillog
To forcefully do this, execute the command:
logrotate -dvf /etc/logrotate.d/mail
Also, to take this effect, ensure that following entry is available in logrotate.conf.
-----
include /etc/logrotate.d
-----
Main directives in logrotate.conf::
weekly : configuration option ensures a weekly rotation of all log-files defined in main configuration file and in /etc/logrotate.d/ directory.
rotate <no> : ensures that logrotate keeps a 4 weeks backup of all log files
create : option instructs logrotate to create new empty log files after each rotation
dateext : appends an extension to all rotated log files in form of date when each particular log file was processed by logrotate
include : all other configuration from directory /etc/logrotate.d
Main directives in additional logrotate services::
missingok : do not output error if logfile is missing
notifempty : donot rotate log file if it is empty
compress : Old versions of log files are compressed with gzip(1) by default
size : Log file is rotated only if it grow bigger than 20k
daily : ensures daily rotation
create - creates a new log file wit permissions 600 where owner and group is root user
Logrotate in plesk.
Logrotate configuration in Plesk.
#/usr/local/psa/etc/logrotate.conf
Plesk calculate mail log statistics from the file /var/log/maillog.processed
This file is updated from " /var/log/maillog" when daily maintenance script execute. Execute the below daily maintenance sript.
#/usr/local/psa/bin/sw-engine-pleskrun /usr/local/psa/admin/plib/DailyMaintainance/script.php
Verify that all the entries in maillog will be moved to maillog.processed. Sample entry in
#/usr/local/psa/etc/logrotate.conf
---
/var/log/maillog.processed {
missingok
rotate 3
size 10M
compress
nocreate
}
---
Function:
1. To reduce the disk space by removing old logs, depending upon the configuration file(/etc/logrotate.conf).
2. Systematic divion of logs without combining all logs in single file.
Features:
1. Possible to create seperate logrotae files in /etc/logrotate.d
Ex. To create logrotate for mail, create a file /etc/logrotate.d/mail and add the below entry.
/var/log/maillog {
rotate 1
daily
size 10k
missingok
rotate 52
compress
delaycompress
notifempty
create 640 root adm
sharedscripts
postrotate
/etc/init.d/postfix reload > /dev/null
endscript
}
To execute logrotate now, execute the command:
#logrotate /var/log/maillog
To forcefully do this, execute the command:
logrotate -dvf /etc/logrotate.d/mail
Also, to take this effect, ensure that following entry is available in logrotate.conf.
-----
include /etc/logrotate.d
-----
Main directives in logrotate.conf::
weekly : configuration option ensures a weekly rotation of all log-files defined in main configuration file and in /etc/logrotate.d/ directory.
rotate <no> : ensures that logrotate keeps a 4 weeks backup of all log files
create : option instructs logrotate to create new empty log files after each rotation
dateext : appends an extension to all rotated log files in form of date when each particular log file was processed by logrotate
include : all other configuration from directory /etc/logrotate.d
Main directives in additional logrotate services::
missingok : do not output error if logfile is missing
notifempty : donot rotate log file if it is empty
compress : Old versions of log files are compressed with gzip(1) by default
size : Log file is rotated only if it grow bigger than 20k
daily : ensures daily rotation
create - creates a new log file wit permissions 600 where owner and group is root user
Logrotate in plesk.
Logrotate configuration in Plesk.
#/usr/local/psa/etc/logrotate.conf
Plesk calculate mail log statistics from the file /var/log/maillog.processed
This file is updated from " /var/log/maillog" when daily maintenance script execute. Execute the below daily maintenance sript.
#/usr/local/psa/bin/sw-engine-pleskrun /usr/local/psa/admin/plib/DailyMaintainance/script.php
Verify that all the entries in maillog will be moved to maillog.processed. Sample entry in
#/usr/local/psa/etc/logrotate.conf
---
/var/log/maillog.processed {
missingok
rotate 3
size 10M
compress
nocreate
}
---