Why "DA logrotate" did not keep log filename as date format ?

ساخت وبلاگ
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.

  • *** 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
How to do ?
- /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 (.).
As a result, when logrotate rotates the log file /var/log/directadmin/access.log, it will create a rotated log file with the name /var/log/directadmin/access.log.YYYY-MM-DD.

DirectAdmin Forums...
ما را در سایت DirectAdmin Forums دنبال می کنید

برچسب : نویسنده : ایمان اصلاحی directadmin بازدید : 82 تاريخ : شنبه 31 تير 1402 ساعت: 23:26