文件夹里面的文件生存时间为30分钟,文件生命周期

公司要求扫描后的文件只留30分钟,扫描文件会自动传送到windows共享文件夹下,

在windows 下写脚本不好实现控制文件的生命周期,后来想到可以挂载到linux系统下

让linux去处理,写脚本,然后加入到循环调度里,每5分钟自动执行一次,以下是代码:


# cat clean.sh
#!/bin/bash
#
dpath=/mnt
find $dpath -type f -mmin +30 -exec rm -rf {} \;
[root@ywtest ~]# cat /etc/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
mount -t cifs -o username=xiu,password=xiu //192.168.10.113/scan /mnt/


[root@ywtest ~]# crontab -e

0 6 * * * ntpdate us.pool.ntp.org
*/5 * * * * /root/clean.sh
~
~

posted @ 2015-04-23 17:42  wz0314  阅读(373)  评论(0编辑  收藏  举报