AIX shell log pressure and Deletion

Source: Internet
Author: User

#/Bin/sh

# Add By zhoujf. Free log file;

Dir_list = "/product1/port/bin/ocs_subscriber_import/back"

Log_list = "* 201 *. unl"

Gz_day = 3
Del_day = 30
Core_day = 7

Cur_time = 'date + "% Y % m % d % t "'
Echo "start at [$ cur_time]"

For dir in $ dir_list
Do
If [! -D $ dir]; then
Echo "[$ dir] is not existed! "
Continue;
Fi

Echo "Enter directory [$ dir]"
CD $ dir
For log_part in $ log_list
Do
# Echo $ log_part
Find $ Dir-name "$ log_part"-type F-ctime + $ gz_day
# Find $ Dir-name "$ log_part"-type F-ctime + $ gz_day | grep-V. GZ | xargs-I gzip-f {}
# Find $ Dir-name "$ log_part"-type F-ctime + $ del_day | grep. GZ | xargs-I RM {}
Done

Done

Cur_time = 'date + "% Y % m % d % t "'
Echo "end at [$ cur_time]"
Echo ""

Exit 0

 

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.