shell脚本删除过期日志的例子

发布时间:2020-06-17编辑:脚本学堂
本文介绍了用shell脚本删除过期日志的方法,find命令的综合例子,有需要的朋友参考下。

例子,shell/ target=_blank class=infotextkey>shell脚本删除过期日志,用linuxjishu/14008.html target=_blank class=infotextkey>find命令查找过期日志文件

代码:
 

复制代码 代码示例:
#! /bin/bash 
#
# Scripts for delete expire loggs 
# www.jb200.com
 
currDate=`date -d today +"%F %r"` 
baseLogPath=/home/Gzh/shell/ 
weblogPath=/usr/local/OA/jboss-cw-oa/logs/ 
 
find "${weblogPath}" -mtime +2 -type f -name "catalina.out.*" >> ${baseLogPath}del_expire.log 
find "${weblogPath}" -mtime +2 -type f -name "catalina.*.log" | xargs rm -rf 
find "${weblogPath}" -mtime +2 -type f -name "catalina.out.*" | xargs rm -rf 
 
echo "delete expire log successfully at ${currDate}" >> ${baseLogPath}del_expire.log