Ttserver log splitting script

Source: Internet
Author: User

[Root @ localhost ~] # Cat/shell/ttserver/ttserver-clear.sh
#! /Bin/bash
Find/var/-name ttserver. log | xargs du-m>/shell/ttserver-log-list
While read line
Do
SIZE = $ (echo $ line | awk '{print $1 }')
FILENAME = $ (echo $ line | awk '{print $2 }')
If [$ SIZE-ge 500]
Then
Echo $ FILENAME
Cp $ {FILENAME }$ {FILENAME}-$ (date + % Y % m % d)
Cat/dev/null >$ {FILENAME}
Fi
Done </shell/ttserver-log-list
 
Logrotate
[Root @ localhost logrotate. d] # cat ttserver
/Var/log/ttserver/log {
Daily splitting
File suffix after dateext splitting
Rotate 4 retain 4 files
Split when the size of 2 k logs reaches 2 k
Copytruncate: copy the old file instead of mv.
Compress compresses new files
}
For how to use logrotate, man logrotate.
This article only shows you how to use this system rotation tool.

Author "Forget Zhennan"

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.