话说写一个脚本也真是不容易,语法什么的,参数什么的,标点符号什么的都要用的恰到好处才能准确执行呀。真是不容易。
[root@test ~]# cat qingli.sh
#!/bin/bash
path1="/opt/jboss/jboss-5.1.0.GA/server/sesb2intf/log"
path2="/opt/jboss/jboss-5.1.0.GA/server/sesb2mgmt/log"
path3="/opt/jboss-eap-6.2/standalone/log"
for path in ${path1} ${path2} ${path3}
do
Time=`date '+%Y%m%d_%H%M'`
echo "==================${Time}_start_cleanlog=================="
ls -ltr ${path}
if [ `du -sm ${path} | awk '{print $1}'` -ge 900 ]
then
cd ${path}
if [ `ls -l ${path} | wc -l` -ge 5 ]
then
rm -rf `ls -rt ${path}|head -n2`
fi
for i in `find ${path} -type f`
do
cat /dev/null > ${i};
done
exit 0
fi
done
本文转自aaa超超aaa 51CTO博客,原文链接:http://blog.51cto.com/10983441/1826739