1、创建一个文本,命名为deLog.sh.
2.编辑文本,输入以下内容:
#!/bin/bash
#tomcat日志清除脚本
function getPath()
{
wmsLogPath="/WMSlogs所在路径"
##wmsLogPath 是WMS对应的路径,若有多个,可复制粘贴后修改对应路径
}
function delLog()
{
echo -e "\033[0;36mDelete the log files before 7 days...\033[0m"
find $wmsLogPath -name '*log*' -mtime +7 -exec rm -rf {} \;
##find $wmsLogPath 是寻找此路径下名字包含log,时间为七天之前的数据并删除掉。
##若有多个,可复制粘贴后修改对应路径
echo -e "\033[0;36mDelete success...\033[0m"
}
main()
{
getPath
delLog
}
main