Timed log output to the specified directory and packaged
1#!/bin/Bash2 3 Backuplog ()4 {5fromdir=$1;6todir=$2;7 8 if[[-Z"$FROMDIR"|| -Z"$TODIR"]]; Then9 Echo "parameter error!";Ten return; One fi A - if[!-d $TODIR]; Then - mkdir-P $TODIR the fi - - CD $FROMDIR - Find. -name"*.log.*"|awk-F" " '{Sub ("./", "");p rint $}'|Xargs-I.CP "{} "$TODIR/{} + CD $TODIR - Find. -name"*.log.???? -?? -??"-execTar-zcf"{}.tar.gz" {} \; + Find. -name"*.log.???? -?? -??"|awk-F/'{Sub ("./", "");p Rint}'|Xargs RM-RF; A } at -guangsoft=/opt/Guanghehome -logdir=/opt/Log - -Backuplog $GUANGSOFT/guanghe/logs $LOGDIR/guanghe
Timed synchronization log to the specified directory
1#!/bin/Bash2 3 Transferlog ()4 {5fromdir=$1;6todir=$2;7files=$3;8 9 if[[-Z"$FROMDIR"|| -Z"$TODIR"|| ${#FILES [@]}-le0]]; ThenTen Echo "parameter error!"; One return; A fi - - if[!-d $TODIR]; Then the mkdir-P $TODIR - fi - - forVarinch${files[*]} + Do - CP-R $FROMDIR/$VAR $TODIR/$VAR + Done A at } - -guangsoft=/opt/Guanghehome -logdir=/opt/Log -Files= (Info. Log debug.log Error.log) - inTransferlog $GUANGSOFT/guanghe/logs $LOGDIR/Guanghe $FILES - to +
Periodically move the application log to the specified directory