Windows实现归档日志自动删除
原创
©著作权归作者所有:来自51CTO博客作者Liujun_Deng的原创作品,请联系作者获取转载授权,否则将追究法律责任
文档课题:Windows实现归档日志自动删除.
系统:Windows 11
1、rmarch.rcv
run{
crosscheck archivelog all;
delete noprompt expired archivelog all;
delete noprompt archivelog until time 'sysdate-5';
}
exit
2、rmarch.bat
语法1:
@echo off
set DaysAgo=0
set LogPath=D:\app\rman_scripts\
forfiles /p %LogPath% /m *.log /d -%DaysAgo% -c "cmd /c del /q @FILE"
set ORACLE_SID=orcl
set h=%time:~0,2%
set h=%h: =0%
set RMARCHDATE=%date:~0,4%%date:~5,2%%date:~8,2%%h%%time:~3,2%%time:~6,2%
rman target '/' @D:\app\rman_scripts\rmarch.rcv log=D:\app\rman_scripts\rm_archive_%RMARCHDATE%.log
语法2:
rman target '/' @D:\app\rman_scripts\rmarch.rcv log=D: \app\rman_scripts\rm_archive.log append
append:日志追加.
然后将rmarch.bat添加到自动维护任务中.