Difference between revisions of "Magento Log Rotate with logrotate"
From Brian Nelson Ramblings
(→Lets create the logrotate configuration file) |
|||
| (One intermediate revision by the same user not shown) | |||
| Line 14: | Line 14: | ||
/path/to/magento/var/log/*log { | /path/to/magento/var/log/*log { | ||
| − | + | compress | |
| − | + | delaycompress | |
| − | + | dateext | |
| − | + | missingok | |
| − | + | nosharedscripts | |
| + | notifempty | ||
| + | daily | ||
| + | rotate 14 | ||
| + | prerotate | ||
| + | /usr/local/bin/ok2rotate $1 | ||
| + | endscript | ||
} | } | ||
| Line 24: | Line 30: | ||
@daily /usr/sbin/logrotate -f /path/to/magento-logrotate.conf | @daily /usr/sbin/logrotate -f /path/to/magento-logrotate.conf | ||
| + | |||
| + | or | ||
| + | 0 0 * * * /usr/sbin/logrotate -f /path/to/magento-logrotate.conf | ||
This will compress the old logs and keep 7 days worth of logs | This will compress the old logs and keep 7 days worth of logs | ||
Latest revision as of 00:02, 13 February 2025
Magento Log Rotate with logrotate
Have you ever had your Magento logs get so large you run out of disk quota. Maybe you would like to setup a log rotation for your Magento logs, it only makes sense all other major logs get rotated...right.
Let setup a cron that will rotate your magento logs (exception.log && system.log).
Lets create the logrotate configuration file
note, you will need to set your path to log files
vim magento-logrotate.conf
now add the following to the magento-logrotate.conf file
/path/to/magento/var/log/*log {
compress
delaycompress
dateext
missingok
nosharedscripts
notifempty
daily
rotate 14
prerotate
/usr/local/bin/ok2rotate $1
endscript
}
Add a Daily cron to rotate your logs
@daily /usr/sbin/logrotate -f /path/to/magento-logrotate.conf
or
0 0 * * * /usr/sbin/logrotate -f /path/to/magento-logrotate.conf
This will compress the old logs and keep 7 days worth of logs