目录下文件超过500自动清理

#!/bin/bash
function spool () {
cd /var/spool/mqueue-client
if [ `ls -lR|grep "^-"|wc -l` -gt 500 ];
    then
	for r in `ls -ltR|tail -n 100`
    do
	rm -rf $r
    done
else
	continue
fi
}
spool
exit

猜你喜欢

转载自blog.csdn.net/wanchaopeng/article/details/80824314