如果想要修改crontab,一般做以下的几步就可以了 
将crontab 推到一个自定义的文件上 
crontab -l>;tmp 
编辑这个文件,做需要的修改 
vi tmp 
推回crontab 
crontab tmp 
 
 
 
#!/bin/sh
DELDIR="/root/crontab_test/test"
 
#3 minute ago
DELTIME="-mmin +3"
 
#delete file type
FILETYPE1="'*.txt'"
FILETYPE2="'*.log'"
 
 
#write to tmp file
rm crontab_del_3min -f
touch crontab_del_3min
#-maxdepth 1 不删除子目录
# every minute delete *.txt file 3 minutes ago
echo \* \* \* \* \* find $DELDIR -maxdepth 1 $DELTIME -name $FILETYPE1 -exec rm -f {} \\\; >> crontab_del_3min
# every minute delete *.log file 3 minutes ago
echo \* \* \* \* \* find $DELDIR -maxdepth 1 $DELTIME -name $FILETYPE2 -exec rm -f {} \\\; >> crontab_del_3min
 
 
#write to crontab
crontab crontab_del_3min
 
#restart to crontab
/etc/init.d/crond restart
04-15 09:08