The shell script that backs up Tomcat logs on Linux every week __linux

Source: Internet
Author: User

Background information:

The project has two log folders, one for Tomcat itself, and two for the project.

This script is used in conjunction with Crontab once a week and can be done without restarting the Tomcat catalina.out normal situation to achieve the function of log backup.

#!/bin/sh
#
#2016 -3-25
#andre. Yang
log_path=/home/app/logs
#tomcat_dir = ' dirname $ '
catalina_path=/home/app/apache-tomcat-7.0.57
Back_path=/home/app/portal_bak Find

${catalina_path}/logs- Mtime +6-name "*.log"-exec rm-rf {} \;

Find ${log_path}/portal-mtime +6-name "*.log"-exec rm-rf {} \;

d= ' Date +%y-%m-%d '
cd ${catalina_path} && tar-czvf $d. tomcatlog.tar.gz logs
mv $d. tomcatlog.tar.gz $ {Back_path}
For I in ' find. -name "*.out"; Do cat/dev/null > $i; Done to
I in ' Find.-name ' *.log ', do cat/dev/null > $i, done

cd ${log_path} && tar-czvf $d. log.t ar.gz Portal
mv $d. Log.tar.gz ${back_path} for
i-' Find-name ' *.log ', do cat/dev/null > $i;

Related Article

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.