[Root @ localhost ~] # Cat/shell/ttserver/ttserver-clear.sh #! /Bin/bashfind/var/-namettserver. log | xargsdu-m & gt;/shell/ttserver-log-listwhilereadlinedoSIZE $ (e
[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"