суббота, 26 февраля 2022 г.

Linux logrotate twice per day

Before:

/etc/logrotate.d/logs

/mnt/shared/project/var/log/*.log 

{
  su www-project www-data
  rotate 30
  daily
  missingok
  compress
  notifempty
  copytruncate
  dateext

}

After:

1) create a separate additional logrotate conf file /etc/logrotate.d/logs_erp with content below (increased twice rotate 30 -> 60 and plus delaycompress):

/etc/logrotate.d/logs_erp
/mnt/shared/project/var/log/erp.log 
{
  su www-project www-data
  rotate 60
  daily
  missingok
  compress
  delaycompress
  notifempty
  copytruncate
  dateext
}
2) modify current logrotate conf file /etc/logrotate.d/logs with excluding first 'erp' characters from wildcard:
/mnt/shared/project/var/log/[!e][!r][!p]*.log 
{
  su www-project www-data
  rotate 30
  daily
  missingok
  compress
  notifempty
  copytruncate
  dateext
}
3) run logrotate conf file /etc/logrotate.d/logs_erp by cron additionally at 18.25
under root account
25 18 * * * logrotate -f /etc/logrotate.d/logs_erp

Комментариев нет:

Отправить комментарий