![7日後のログ循環とアーカイブの削除[閉じる]](https://linux33.com/image/143048/7%E6%97%A5%E5%BE%8C%E3%81%AE%E3%83%AD%E3%82%B0%E5%BE%AA%E7%92%B0%E3%81%A8%E3%82%A2%E3%83%BC%E3%82%AB%E3%82%A4%E3%83%96%E3%81%AE%E5%89%8A%E9%99%A4%5B%E9%96%89%E3%81%98%E3%82%8B%5D.png)
logrotate
特定のディレクトリで7日以上古いすべてのログファイルを見つけてアーカイブするように設定しようとしています。アーカイブファイルを削除する必要があります。
私の構造は次のとおりです。
/var/log/myapp/subfolder1/*.log (hundreds of logs)
/var/log/myapp/subfolder2/*.log (hundreds of logs)
/var/log/myapp/subfolder3/*.log (hundreds of logs)
/var/log/myapp/subfolder4/*.log (hundreds of logs)
に構成ファイルを作成する必要があることを知っていますが、/etc/logrotate.d/
各ディレクトリで7日以上古いログファイルのアーカイブを指定し、アーカイブされたファイルを削除するにはどうすればよいですか。
答え1
#While waiting for a real answer, you may wish to play w/ the following
#following alternative outline of a solution not using "logrotate"
#Needs sanity checks, failure recovery, et cetera
find $myLOGHOME -type f -mtime -7 | tee $myARCHIVE_FILES
#After archiving & renaming old files, $mySTREAM_ARCHIVER moves
#the originals to a holding directory, where they will be maintained
#for some time before eventually being deleted when they are too old
#Holding directory files remain there
$mySTREAM_ARCHIVER $myOPTIONS < $myARCHIVE_FILES
#Implementation, testing and cleanup are left as an exercise for the reader