Closed. This question is off-topic. It is not currently accepting answers. Learn more
想改进这个问题吗?Update the question所以堆栈溢出的值小于aa>。
5年前关闭。
我需要每10分钟运行一个shell脚本。
每次脚本运行时,我都会将输出追加到日志文件中。
当日志文件的大小达到10 MB时,我需要停止脚本的运行。
怎么能做到这一点,请帮忙!!
./test.sh >> log_file

最佳答案

maximumsize=10000 #KB

while :
do
    ./test.sh >> log_file
    actualsize=$(du -k log_file | cut -f 1)
    if [ $actualsize -gt $maximumsize ];then
        echo "logsize exceed.stop."
        break
    fi

    sleep 600
done

09-10 01:15
查看更多