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