0
点赞
收藏
分享

微信扫一扫

Fdfs上传的图片批量删除

在/home/data目录下创建 clear.sh脚本 # 内容如下: #!/bin/sh find /root/fastdfs/storag* -mtime + 30 -type f -name "*.png" -exec rm -rf {} \; find /root/fastdfs/storag* -mtime + 30 -type f -name "*.jpg" -exec rm -rf {} \; find /root/fastdfs/storag* -mtime + 30 -type f -name "*.mp4" -exec rm -rf {} \;

介绍:

因为计划利用fdfs上传的图片会有很多,所以在考虑到重复利用的情况下,把半年前的图片删除掉.

1)编写清理图片脚本clear.sh

在/home/data目录下创建 clear.sh脚本

内容如下:

!/bin/sh

find /root/fastdfs/storag* -mtime + 30 -type f -name ".png" -exec rm -rf {} ;
find /root/fastdfs/storag
-mtime + 30 -type f -name ".jpg" -exec rm -rf {} ;
find /root/fastdfs/storag
-mtime + 30 -type f -name "*.mp4" -exec rm -rf {} ;

说明:

/root/fastdfs/storag* 是路径,目前计算的是每一个硬盘使用一个路径.现在这里有2个硬盘

-mtime +30 是时间 这个配置是删除修改时间是30天前的

-type f 删除的是文件类型

-name "*.png" 删除名称为 后缀是.png的文件

2)给脚本授权

chmod +x clear.sh

3)加入定时执行任务

vi /etc/crontab

在最后加入:45 14 * * * root /root/fastdfs/clear.sh

Fdfs上传的图片批量删除_修改时间

说明:每天的14点45开始运行/root/fastdfs/clear.sh 这个脚本


你的压力来源于无法自律,只是假装努力,现状跟不上内心欲望,所以你焦虑又恐慌。——杨不易




举报

相关推荐

0 条评论