神剑山庄资源网 Design By www.hcban.com
1、tools目录文件结构
[root@www tools]# tree tools/ tools/ ├── bin │ ├── del_history_files │ └── etc ├── del_history_files.cfg 2 directories, 2 files
2、删除历史文件脚本 del_history_files
[root@www tools]# more tools/bin/del_history_files #!/bin/sh # 删除指定目录下,文件时间早于指定时间节点的文件,时间粒度:小时 # 配置文件格式 : 需清理的目录=小时数 # # # define restricted path PATH="/bin:/usr/bin:/sbin:/usr/sbin" # adirname - return absolute dirname of given file adirname() { odir=`pwd`; cd `dirname $1`; pwd; cd "${odir}"; } # --------- # constants # --------- MYNAM=`basename "$0"` MYDIR=`adirname "$0"` MYCFG="${MYDIR}/../etc/${MYNAM}.cfg" MYTMP="${MYDIR}/../tmp" MYLCK="${MYTMP}/${MYNAM}.lock" # perform some locking (as good as it gets in a shell) [ -s "${MYLCK}" ] && kill -0 `cat "${MYLCK}"` 2>/dev/null && die "${MYNAM}: already running!" echo "$$" > "${MYLCK}" PATHS=(`cat ${MYCFG}`) for PP in ${PATHS[@]} do APP_PATH=`echo ${PP} | awk -F'=' '{print $1}'` N=`echo ${PP} | awk -F'=' '{print $2}'` if [ -d ${APP_PATH} ] ; then T=`/bin/date --date "${N} hours ago" "+%Y%m%d%H%M"` TMP_FILE="/tmp/`echo ${PP} | md5sum | awk '{print $1}'`" touch -t ${T} ${TMP_FILE} find ${APP_PATH} ! -newer ${TMP_FILE} -type f -print0 | xargs -0 -n 100 rm -rf find ${APP_PATH} -type d -empty -print0 | xargs -0 -n 100 rm -rf &> /dev/null fi done rm -rf ${MYLCK}
3、删除历史文件脚本的配置文件 del_history_files.cfg
[root@www tools]# more tools/etc/del_history_files.cfg #需清理的目录=小时数 /home/logs/nginx=720 /home/logs/varnish=720
4、crontab 执行即可
[root@www tools]# more /etc/crontab SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root HOME=/ #clear old logs 00 6 * * * root /home/tools/bin/del_history_files
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
神剑山庄资源网 Design By www.hcban.com
神剑山庄资源网
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
神剑山庄资源网 Design By www.hcban.com
暂无Linux使用shell脚本定时删除历史日志文件的评论...
P70系列延期,华为新旗舰将在下月发布
3月20日消息,近期博主@数码闲聊站 透露,原定三月份发布的华为新旗舰P70系列延期发布,预计4月份上市。
而博主@定焦数码 爆料,华为的P70系列在定位上已经超过了Mate60,成为了重要的旗舰系列之一。它肩负着重返影像领域顶尖的使命。那么这次P70会带来哪些令人惊艳的创新呢?
根据目前爆料的消息来看,华为P70系列将推出三个版本,其中P70和P70 Pro采用了三角形的摄像头模组设计,而P70 Art则采用了与上一代P60 Art相似的不规则形状设计。这样的外观是否好看见仁见智,但辨识度绝对拉满。
更新日志
2024年09月19日
2024年09月19日
- 李丽蕊.1987-伤心天使(2006复黑版)【永恒】【WAV+CUE】
- 群星.1990-金装偶像精丫SONY】【WAV+CUE】
- 钟尚荣.1995-只愿一生牵着你的手【波丽佳音】【WAV+CUE】
- 【原神】V5.0攻略 | 73个浪沫羽鳃采集路线—玛拉妮
- 【原神】V5.0攻略 |「雷电将军」一图流丨角色解析攻略
- 《原神》4.7被埋藏的荣耀任务怎么做?
- 尤雅.1995-情海茫茫【怀登唱片】【WAV+CUE】
- 张宇.1995-一言难揪EMI百代】【WAV+CUE】
- 尹毓恪.2018-浴室与太平洋【海蝶】【FLAC分轨】
- 《遗迹2:黑暗的视界》发布全新职业护卫者预告片,将于9月25日上线
- 好评如潮《彼方的她》迎来首次大型更新
- 《最终幻想16》PC版震撼登场 官方发布精彩宣传片
- 《中国十大国语老歌.男人篇 3CD》[WAV/分轨][1.5GB]
- 《汽车音响极品流行热曲发烧大碟 情伤 男声篇2CD》[WAV/分轨][980MB]
- 《绝版经典情歌 国语老歌 内地珍藏篇 2CD》[WAV/分轨][1.2GB]