Periodically move the application log to the specified directory

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.