Shell script to clean up logs
------------------------------------------------------------------------------------------------
#!/bin/bash
tomcatnum=2
#清理的路径 tomcat[0]= "/usr/local/tomcat/logs"
tomcat[1]= "/data/logs/tomcat0"
For ((i=0;i< $tomcatnum; i++));d o
echo "Deleting ${tomcat[i]}"
RM-RF ${tomcat[i]}/*
#echo $i
Done
Tom_catalog= "Tomcat"
#根据tomcat名称进行查询
process_num=$ (ps-ef|grep "$tom _catalog" |grep-v "grep" |wc-l)
#得到pid
#pid =$ (ps-ef|grep "$tom _catalog" |grep-v "grep" | awk ' {print $} ') echo $PROCESS _num
If [$PROCESS _num-ge 1];
Then
Echo ' Tomcat is stopping ... '
/usr/local/tomcat/bin/shutdown.sh
#kill-9 $pid Sleep 200
echo "Tomcat is running ..."
/usr/local/tomcat/bin/startup.sh
Else
Echo ' Tomcat is running '
/usr/local/tomcat/bin/startup.sh
Fi
_____________________________________________________
Add the shell script to the timer boot
/var/spool/cron/
VI Root
0 * * 6/usr/local/script/***.sh
Restart Corn
/sbin/service Cron Restart