How to make custom logrotate script
Posted: Wed Aug 24, 2022 12:29 pm
Let's suppose that you want to crete new logrotate script in order to gzip some custom log files (we will take them as examples here).
Additionally, let's say we want to save the log archives only for the last 10 days.
In your SSH, as root, run:
Here you will create file like this (instead of someuser insert desired user):
And then run the test:
And finally real initial run:
Additionally, let's say we want to save the log archives only for the last 10 days.
In your SSH, as root, run:
Code: Select all
mcedit /etc/logrotate.d/custom
Code: Select all
/home/someuser/web/domain.com/public_html/var/log/*.log {
daily
size 1M
missingok
rotate 10
compress
delaycompress
notifempty
create 0644 someuser someuser
su someuser someuser
}
Code: Select all
logrotate -d -f /etc/logrotate.d/custom
Code: Select all
logrotate -f /etc/logrotate.d/custom