Why "DA logrotate" did not keep log filename as date format ?
logrotate use filename.date is better than filename.number
because all log no need to change the filename every day.
Now logrotate format
/var/log/exim/mainlog , /var/log/exim/mainlog.1 , /var/log/exim/mainlog.2
/var/log/directadmin/error.log, /var/log/directadmin/error.log.1 , /var/log/directadmin/error.log.2 ...
Example log filename.date
- /etc/logrotate.d/directadmin
In the above configuration, two additional directives are included:
logrotate use filename.date is better than filename.number
because all log no need to change the filename every day.
- *** Reduce the time for rsync backup (It greatly reduces the processing time)
- *** Reduce the time on snapshort backup
- *** Reduce snapshort storage size,
- Easy to find , read and view the log content
- Easy to remove older log
Now logrotate format
/var/log/exim/mainlog , /var/log/exim/mainlog.1 , /var/log/exim/mainlog.2
/var/log/directadmin/error.log, /var/log/directadmin/error.log.1 , /var/log/directadmin/error.log.2 ...
Example log filename.date
- /var/log/exim/mainlog
- /var/log/exim/mainlog.2023-06-17
- /var/log/exim/mainlog.2023-06-16
- /var/log/exim/mainlog.2023-06-15
- /var/log/directadmin/access.log
- /var/log/directadmin/access.log.2023-06-17
- /var/log/directadmin/access.log2023-06-16
- /var/log/directadmin/access.log.2023-06-15
- /etc/logrotate.d/directadmin
Code:
/var/log/directadmin/access.log {
daily
rotate 21
missingok
nocreate
dateext
dateformat .%Y-%m-%d
}
In the above configuration, two additional directives are included:
- dateext: This directive tells logrotate to append the date to the rotated log file name.
- dateformat .%Y-%m-%d: This directive specifies the format of the appended date. In this example, the date will be in the format of YYYY-MM-DD and preceded by a dot (.).
Last edited: