如何更改合并文件的目标位置?

如何更改合并文件的目标位置?
timestamp=$(date +%Y%m%d_%H%M%S)
mDir=`dirname $0`
filename=purge_log_$timestamp.log
log=$mDir/log/$filename

purge_path="sf2212f/vendors/jboss5/jboss-eap-6.4/d/log"
bz_purge_retention=60
log_compress_retention=2

START_TIME=$(date +%s)
echo "*** Purge Log Files for path [$purge_path] Started :: $(date +%Y%m%d_%H%M)" >> $log

# purge the old files in log folder
find $purge_path/* -name "webapp_dbs1*bz2" -type f -mtime +"${bz_purge_retention}" -print -delete >> $log
find $purge_path/* -name "webapp_access_d*bz2" -type f -mtime +"${bz_purge_retention}" -print -delete >> $log
find $purge_path/* -name "eventprocess_d*bz2" -type f -mtime +"${bz_purge_retention}" -print -delete >> $log
find $purge_path/* -name "server_u_dbs1*bz2" -type f -mtime +"${bz_purge_retention}" -print -delete >> $log

echo "*** Purge Log Files for path [$purge_path] Completed :: $(date +%Y%m%d_%H%M)" >> $log

echo "*** Compress Files for path [$purge_path] Started :: $(date +%Y%m%d_%H%M)" >> $log

#compress the old files in log folder
find $purge_path/* -name "webapp_d*" -type f -mtime +"${log_compress_retention}"|egrep -v '\.bz2'|xargs bzip2 >> $log
find $purge_path/* -name "webapp_access_d*" -type f -mtime +"${log_compress_retention}"|egrep -v '\.bz2'|xargs bzip2 >> $log
find $purge_path/* -name "eventprocess_dbs1*" -type f -mtime +"${log_compress_retention}"|egrep -v '\.bz2'|xargs bzip2 >> $log
find $purge_path/* -name "server_u_d*" -type f -mtime +"${log_compress_retention}"|egrep -v '\.bz2'|xargs bzip2 >> $log

END_TIME=$(date +%s)
echo "*** Compress Files for path [$purge_path] Completed :: $(date +%Y%m%d_%H%M)" >> $log

ELAPSED_TIME=$(($END_TIME - $START_TIME))
hr=$(($ELAPSED_TIME / 3600))
hr_mod=$(($ELAPSED_TIME % 3600))
mm=$(($hr_mod / 60))
ss=$(($hr_mod % 60))

echo "*** Purge Log Files for path [$purge_path] took [$ELAPSED_TIME] seconds, Elapsed Time ::  $(date -d $hr:$mm:$ss +%Hh:%Mm:%Ss)"  >> $log

答案1

它正在做一些事情:

  • 查找/068fs01/vendors/jboss5/jboss-eap-6.4/dbs1/log命名的日志文件。
  • bz_purge_retention删除这些日志文件的旧的(由定义)“备份”。
  • 如果 bzip 备份比要求的旧,则创建新的 bzip 备份log_compress_retention
  • 回显大量内容来告诉您它在做什么以及花费了多长时间放入公共日志文件(在文件顶部定义)。

使用一个常见的短语:日志轮换。

相关内容