定时检查某个目录下文件脚本

来源:互联网 发布:windows dvd 字幕 编辑:程序博客网 时间:2024/05/20 09:48

定时检查某个目录下后缀为.txt的文件都移到其他目录下,

 

 

#!/bin/bash
# find file
time=`date`
log=/test/log                                             #日志地址
Source_dir=/test/*.txt*                                    #源目录
target_dir=/test1/                                           #目标目录
/bin/mv $Source_dir $target_dir
if [ $? -eq 0 ];then
echo "$time mv file $Source_dir to $target_dir ok" &>> $log
else
echo " $time warning dir $Source_dir no file   " &>> $log
fi