当前位置: > shell编程 >

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

时间:2014-08-20 02:46来源:linux.it.net.cn 作者:it

例子,shell脚本删除过期日志,用find命令查找过期日志文件

代码:
 

复制代码代码示例:
#! /bin/bash  
#
# Scripts for delete expire loggs  
# www.jbxue.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 
(责任编辑:IT)
------分隔线----------------------------
栏目列表
推荐内容