文件大于5M则清空

 

#!/bin/bash

function clear_log
{
    file1="/root/log.txt"
    file2="/root/log2.txt"

    if find ${file1} -size +5120k | grep ${file1} > /dev/null ; then
        cat /dev/null > ${file1}
        cat /dev/null > ${file2}
    fi

    if find ${file2} -size +5120k | grep ${file2} > /dev/null ; then
        cat /dev/null > ${file1}
        cat /dev/null > ${file2}
    fi
}

clear_log

 

posted @ 2024-10-12 16:37  LiuYanYGZ  阅读(11)  评论(0编辑  收藏  举报