como alterar o local de destino dos arquivos para mesclagem?

-3
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
    
por user3168020 09.02.2017 / 12:20

1 resposta

1

Está fazendo algumas coisas:

  • Procurando em /068fs01/vendors/jboss5/jboss-eap-6.4/dbs1/log para arquivos de log nomeados.
  • Excluindo "backups" antigos (definidos por bz_purge_retention ) desses arquivos de log.
  • Criando novos backups de bzps se forem mais antigos que log_compress_retention de demandas.
  • Fazendo eco de um monte de coisas para dizer o que está fazendo e quanto tempo leva para um arquivo de log comum (definido na parte superior do arquivo).

Para usar uma frase comum: rotação de log.

    
por Oli 09.02.2017 / 12:40