logrotate: オープン中にエラーが発生しました (該当するファイルやディレクトリはありません)。

logrotate: オープン中にエラーが発生しました (該当するファイルやディレクトリはありません)。

エラーメッセージが表示されます。メールで自動送信されます。

/etc/cron.daily/logrotate:
error: error opening /var/log/apache2/access.log.1.gz: No such file or directory
error: error opening /var/log/apache2/myhost/access.log.1.gz: No such file or directory

私も私のディレクトリ/var/log/apache2/*/var/log/apache2/myhost/*そのディレクトリをチェックします。そのファイルはありませんが、access.log.1.gzディレクトリにファイルが必要です。access.log.1私はちょうど私のログファイルを管理するためにこのツールを設定し始めましたlogrotate。私のApacheは長い間実行されており、私のディレクトリに少なくとも30個のログファイルがあります。現時点では、なぜこれが起こるのかわかりません。

私の/etc/logrotateものは次のとおりです。

/var/log/apache2/*.log {
     daily
     missingok
     rotate 10
     compress
     delaycompress
#    notifempty
     create 640 root adm
     sharedscripts
     postrotate
                 /etc/init.d/apache2 reload > /dev/null;
     endscript
     prerotate
             if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
                     run-parts /etc/logrotate.d/httpd-prerotate; \
             fi; \
     endscript
}
/var/log/apache2/myhost/*.log {
     daily
     missingok
     rotate 10
     compress
     delaycompress
#    notifempty
     create 640 root adm
     sharedscripts
     postrotate
             /etc/init.d/apache2 reload > /dev/null; \
     endscript
     prerotate
             if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
                     run-parts /etc/logrotate.d/httpd-prerotate; \
             fi; \
     endscript
}

ベストアンサー1

修正しました。私の新しい設定は2つの場所で変更されました。これで、 /var/log/apache2/myhost/ は、別途「access.log.1」と「error.log.1」なしで以下のようになります。

私の/etc/logrotate.dの設定は次のとおりです。アスタリスクを削除し、具体的に名前を付けました。それ以外の場合は、「delaycompress」ディレクティブにコメントを付けます。
/var/log/apache2/myhost/access.log /var/log/apache2/myhost/error.log { daily missingok rotate 2 compress # delaycompress # notifempty create 640 root adm sharedscripts postrotate /etc/init.d/apache2 reload > /dev/null; \ endscript }

ここに/etc/logrotate.confファイルを追加しました。私も「圧縮」について言及しました。次に、「sudo logrotate -f /etc/logrotate.d/apache2」を実行します。これは、この実行を強制的に実行することを意味します。結果は素晴らしいです。みんなありがとうございます。

# 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
</code>

おすすめ記事