文件大于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