2008年(8065)
分类: 服务器与存储
2008-05-21 09:21:49
每次运行数据泵时它需要为数据泵文件取一个新名字,与导出不同,它不会覆盖旧的数据泵文件,因此以前在夜间调度执行的数据泵导出文件需要被移除,下面是批处理文件:
代码清单10:
set CURDIR=D:\oracle\admin\common\batch cd %CURDIR% set logfile=logs\delete_Xdrive_expdp_files.log echo 'logfile = ' %logfile% > %logfile% echo . >> %logfile% echo . >> %logfile% echo '******************************************************' >> %logfile% echo '* The following files will be deleted. *' >> %logfile% echo '******************************************************' >> %logfile% echo . >> %logfile% echo . >> %logfile% FORFILES /p X:\data_pump\DMPs /m *.dmp /d -0 /c "CMD /C echo @PATH\@FILE @FDATE.@FTIME" >> %logfile% echo . >> %logfile% echo . >> %logfile% echo '******************************************************' >> %logfile% echo '* Starting deletes now ... *' >> %logfile% echo '******************************************************' >> %logfile% echo . >> %logfile% echo . >> %logfile% FORFILES /p X:\data_pump\DMPs /d -0 /c "CMD /C del *.dmp" >> %logfile% echo . >> %logfile% echo . >> %logfile% |
这里和我们在其他批处理脚本中看到的一样,首先我们设置好目录然后将脚本放进去,我们也设置了日志文件为一个变量,因为我们将经常使用它,实际上,第一条进入日志文件的条目是日志文件名,使用点的echo命令只是为了让日志可读性更佳,实际上这里只有两条有效的命令,第一条简单地列出即将删除的文件,第二条命令真正地执行删除操作。