1

Ubuntu 12.10 では、次のエントリを「/etc/logrotate.d」パスに追加しました。

# cat /etc/logrotate.d/tsdb
/home/logs/*dat {
        daily
        rotate 30
        compress
        missingok
        notifempty
        create 0664 nagios nagios
}

以下は、「/etc/cron.daily/logrotate」ファイルがどのように見えるかです:

# cat /etc/cron.daily/logrotate
#!/bin/sh

# Clean non existent log file entries from status file
cd /var/lib/logrotate
test -e status || touch status
head -1 status > status.clean
sed 's/"//g' status | while read logfile date
do
    [ -e "$logfile" ] && echo "\"$logfile\" $date"
done >> status.clean
mv status.clean status

test -x /usr/sbin/logrotate || exit 0
/usr/sbin/logrotate /etc/logrotate.conf

ログがローテーションされることを期待していましたが、ローテーションされていません。ここで私が間違っていることは何ですか?

ステータス ファイルには、問題のファイルに対して logrotate が実行されたことが示されていますが、ローテーションされたログは表示されません。

# cat /var/lib/logrotate/status
logrotate state -- version 2
"/home/logs/service-perfdata.dat" 2013-11-26
"/home/logs/host-perfdata.dat" 2013-11-26

また、「/etc/logrotate.conf」ファイルは次のようになります。

# cat /etc/logrotate.conf
# see "man logrotate" for details
# rotate log files weekly
weekly

# keep 4 weeks worth of backlogs
rotate 4

# create new (empty) log files after rotating old ones
create

# uncomment this if you want your log files compressed
#compress

# packages drop log rotation information into this directory
include /etc/logrotate.d

# no packages own wtmp, or btmp -- we'll rotate them here
/var/log/wtmp {
    missingok
    monthly
    create 0664 root utmp
    rotate 1
}

/var/log/btmp {
    missingok
    monthly
    create 0660 root utmp
    rotate 1
}

# system-specific logs may be configured here

logrotate の手動実行の出力は次のとおりです。

# /usr/sbin/logrotate -vd /etc/logrotate.conf

rotating pattern: /home/logs/*dat  after 1 days (30 rotations)
empty log files are not rotated, old logs are removed
considering log /home/logs/host-perfdata.dat
  log does not need rotating
considering log /home/logs/service-perfdata.dat
  log does not need rotating
4

1 に答える 1