• 欢迎访问小杰博客网站
  • 欢迎访问小杰博客网站哦

shell定时删除指定目录下的文件

未分类 小杰 8年前 (2015-12-04) 1210次浏览 已收录 0个评论

contab -e

10 */12 * * * sh /usr/local/apache2/htdocs/cakephp/ebook/webroot/php/delete_big_log.sh

代码:

#!/bin/bash

location=’/var/spool/mail’
find $location -type f -name ‘root’ | xargs rm -f

location=”/var/log/”
find $location -type f -name ‘lsyncd.log’ |xargs rm -f

location=”/usr/local/apache2/htdocs/cakephp/ebook/tmp/logs/”
find $location -type f -name ‘debug.log’ |xargs rm -f
find $location -type f -name ‘error.log’ |xargs rm -f

location=”/usr/local/apache2/htdocs/cakephp/channel/tmp/logs/”
find $location -type f -name ‘debug.log’ |xargs rm -f
find $location -type f -name ‘error.log’ |xargs rm -f

location=”/usr/local/apache2/htdocs/cakephp/client_channel/tmp/logs/”
find $location -type f -name ‘debug.log’ |xargs rm -f
find $location -type f -name ‘error.log’ |xargs rm -f

location=”/usr/local/apache2/logs/”
find $location -mtime +3 -type f  |xargs rm -f
find $location -mtime +3 -type f  |xargs rm -f


小杰博客 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:shell定时删除指定目录下的文件
喜欢 (0)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址