定时任务:
$ crontab -l
#delete archivelog before 7 days
00 02 * * * sh /home/oracle/tkdba/del_arch.sh >> /home/oracle/tkdba/logs/del_arch.log.$(date +%F) 2>&1
观察定时任务没有执行,临时文件没有清理。
通过分析日志/var/log/cron ,这里$(date +%F)未执行。
Jul 15 23:30:01 6305-szdb02 CROND[19000]: (oracle) CMD (sh /home/oracle/tkdba/del_arch.sh >> /home/oracle/tkdba/logs/del_arch.log.$(date +)
修改定时任务的实现方式。
$ crontab -l
#delete archivelog before 7 days
00 02 * * * sh /home/oracle/tkdba/del_arch_everyday.sh
$ cat /home/oracle/tkdba/del_arch_everyday.sh
sh /home/oracle/tkdba/del_arch.sh >> /home/oracle/tkdba/logs/del_arch.log.$(date +%F) 2>&1