Shell Script BACKUP Log

Source: Internet
Author: User

#!/bin/sh# back Tomcat Catalina. outCD/home/Log_bak #the filedate= ' Date'+%y%m%d-%h%m'' ARCHIVE=$DATE. Tar.gzfile="Tomcat_""$DATE. Catalina.out"#开始备份之前, write the backup information header to the journal file Echo" ">>Log.txtecho" ">>Log.txtecho"——————————————— –">>Log.txtecho"BACKUP DATE:"$ (date +"%y-%m-%d%h:%m:%s") >>Log.txtecho"——————————————— –">>log.txtcp/tomcat/logs/catalina. out/home/log_bak/$filesleepTentar czvf $ARCHIVE $file>> Log.txt2>&1#判断catalina. If the out backup was successfulif[[ $? ==0 ]]; Then #创建备份文件的压缩包 # tar czvf $ARCHIVE $LOG>> Log.txt2>&1#输入备份成功的消息到日记文件 echo "[$ARCHIVE] Backup successful! ">>Log.txt>/data/apache-tomcat-7.0. -/logs/catalina. outRM-F $file #只需保留备份文件的压缩包即可Elseecho "Catalina. outBackup fail! ">>log.txtfi# Output backup process end of reminder message echo "Backup process Done"

Shell Script BACKUP Log

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.