
実行するとlogrotate
次のように表示されます。
error: error creating output file /var/log/remote/172.29.202.29/contrail-vrouter-agent.log.1: File exists
error: error creating output file /var/log/remote/172.29.207.139/swift-object-server.log.1: File exists
...
既存のファイルは 1000 個ほどあります。正常に 再実行できるように、log.1
すべての名前を変更したいと思います。***log.2
logrotate
どうすればいいですか?
答え1
一度だけの修正を探しているのであれば、これでうまくいくはずです:
find /var/log/remote/ -maxdepth 2 -type f -name *.log.1 | sed -e 's/log\.1/log\./g' | xargs -i mv {}1 {}2
ただし、これにより名前が変更されることに注意してください全て *.log.1
ファイル/var/log/remote/*/
したがって、スキップしたいディレクトリがある場合は/var/log/remote/
、-not -path <path>
findの後にオプションを使用する必要があります(例として別のスレッドのこの回答)