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

mean

Verified User
Joined
Feb 14, 2007
Messages
108
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.
 
Last edited:
I have never seen them like that, all my logs going a year have just the number. Standard logrotate. I guess if you wanted it that way you need to edit your /etc/logrotate.conf and set dateext
 
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 ...
Did you change anything anywhere?
Because this is not default like @cjd said, we never had it like that.

Exim.
Code:
-rw-r--r--   1 mail mail 474K 2023-05-21 02:23 mainlog-20230521
-rw-r--r--   1 mail mail 474K 2023-05-28 03:22 mainlog-20230528
-rw-r--r--   1 mail mail 237K 2023-06-04 03:30 mainlog-20230604
-rw-r--r--   1 mail mail 275K 2023-06-11 03:06 mainlog-20230611

And DA error log:
Code:
-rw-r--r--   1 diradmin diradmin    0 2023-06-11 03:13 error.log
-rw-r--r--   1 diradmin diradmin    0 2023-05-14 03:41 error.log-20230521
-rw-r--r--   1 diradmin diradmin  195 2023-05-23 23:03 error.log-20230528
-rw-r--r--   1 diradmin diradmin 3.7K 2023-06-02 15:46 error.log-20230604
-rw-r--r--   1 diradmin diradmin    0 2023-06-04 03:36 error.log-20230611

On all our servers, all logrotated from logs created by DA are with date.
 
Hi @Richard G , @cjd

Oh i see , Thank you so much for your answer.
I have encountered this problem for a very long time.

Sorry, I've found the cause of the problem from log backup script will comment "dateext" : P

sed -i 's/^dateext/#dateext/g' /etc/logrotate.conf
sed -i 's/^rotate.*$/rotate 14/g' /etc/logrotate.conf
 
Hi @Richard G , @cjd

Could you please check "User Domain Statistics Logs" in /home/{USER}/domains/{DOMAIN}/logs

file name running as a date, or is there a daily numerical file name update?
in /etc/logrotate.d doesn't have config.

Are you similar to me?
Do you know how to keep the file name as dates ?


1688583913825.png
 
Last edited:
Back
Top