公司要求扫描后的文件只留30分钟,扫描文件会自动传送到windows共享文件夹下,
在windows 下写脚本不好实现控制文件的生命周期,后来想到可以挂载到linux系统下
让linux去处理,写脚本,然后加入到循环调度里,每5分钟自动执行一次,以下是代码:
# cat clean.sh
#!/bin/bash
#
dpath=/mnt
find $dpath -type f -mmin +30 -exec rm -rf {} \;
[[email protected] ~]# 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/
[[email protected] ~]# crontab -e
0 6 * * * ntpdate us.pool.ntp.org
*/5 * * * * /root/clean.sh
~
~
时间: 2024-11-13 09:57:34