Write a Log Poll archive script

Source: Internet
Author: User

Similar to log cutting, the system has a logrotate program to complete the archive. But now we're going to write ourselves a shell script to implement the archive. Example: If the output of the service log is 1.log, I asked to file a daily, 1.log the next day to become 1.log.1, the third day 1.log.2, the fourth day 1.log.3 until 1.log.5.
Here is a reference script for you to refer to:

#!/bin/bashfunction e_df () {[-F $] && rm-f $1}for i in ' seq 5-1 2 ' do i2=$[$i-1] e_df/data/1.log. $i if [-f/data/1.log. $i 2] then Mv/data/1.log. $i 2/data/1.log. $i Fidonee_df/data/1.log.1mv/data/1.log/ Data/1.log.1


This article is from "Linux rookie" blog, please be sure to keep this source http://490617581.blog.51cto.com/11186315/1766500

Write a Log Poll archive script

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.