/var/log/example/*.log { ... sharedscripts postrotate /usr/bin/find /var/log/example/ -type f -size 0 -mmin +7 -delete endscript
/var/log/yum.log { missingok notifempty yearly create 0600 root root compress dateext }
/var/log/yum.log { missingok notifempty yearly create 0600 root root compress lastaction EXT=`/bin/date +%Y%m%d` /bin/mv yum.1.gz yum.log-${EXT}.gz endscript }
sudo logrotate -dv /etc/logrotate.d/syslog ... removing old log /var/log/messages.1 error: error opening /var/log/messages.1: No such file or directory
logrotate -dv /etc/logrotate.d/lsyncd
vi /var/lib/logrotate.status
LANG=C ll /var/log/ | grep zabbix drwxrwxr-x 2 root zabbix 30 Dec 11 20:55 zabbix
/var/log/zabbix/zabbix_agentd.log { missingok notifempty compress create 0664 zabbix zabbix su zabbix zabbix }
sudo systemctl edit logrotate.timer # 以下が自動生成される /etc/systemd/system/logrotate.timer.d/override.conf
systemctl list-timers
sudo zgrep logrotate /var/log/messages 03:10:00 <hostname> logrotate: ALERT exited abnormally with [1]
sudo logrotate -vd /etc/logrotate.conf |& grep ^error ... error: line 100 too long in state file /var/lib/logrotate.status
sudo vim /var/lib/logrotate.status
error: glusterfs:23 glob failed for /var/log/glusterfs/bricks/*.log: そのようなファイルやディレクトリはありません error: stat of /var/log/glusterfs/*.log failed: そのようなファイルやディレクトリはありません
sudo rm /etc/logrotate.d/example.conf.rpmold sudo service crond reload
sudo logrotate -dv -s /var/lib/logrotate/logrotate.status /etc/logrotate.conf;echo $?
STDERRにエラーが出ている可能性がある。デフォルトでは、STDOUTしか/var/log/messagesに出ない。
- /usr/sbin/logrotate -s /var/lib/logrotate/logrotate.status /etc/logrotate.conf + /usr/sbin/logrotate -s /var/lib/logrotate/logrotate.status /etc/logrotate.conf 2>&1
Java製のアプリ等で、シグナルによるログの再生成を行ってくれない場合、ログがrotateされない場合がある。
echo -n > /var/log/example.log
/var/log/nginx/*.log { weekly rotate 4 missingok compress notifempty sharedscripts postrotate [ ! -f /var/run/nginx.pid ] || kill -USR1 `cat /var/run/nginx.pid` endscript }
/var/log/example.log { copytruncate missingok compress notifempty }
yum install cronolog --enablerepo=epel vim /etc/httpd/conf/httpd.conf ---- CustomLog "|/usr/sbin/cronolog /var/logs/logfile.%Y%m%d" common ----
yum install httpd vim /etc/httpd/conf/httpd.conf ---- CustomLog "|/usr/sbin/rotatelogs -l /var/logs/logfile.%Y%m%d 86400" combined ----
対策:
sudo truncate -s 0 /var/log/btmp
cat >> /etc/logrotate.conf << EOS /var/log/btmp { missingok monthly minsize 1M create 0600 root utmp rotate 1 compress } EOS
記事: