ORACLE|ORACLE 定时清理7天前归档日志
[oracle@ORACLE122 ~]$ pwd
/home/oracle
[oracle@ORACLE122 ~]$ mkdir auto_deal
[oracle@ORACLE122 ~]$ cd auto_deal/
[oracle@ORACLE122 auto_deal]$ mkdir /home/oracle/auto_deal/data
[oracle@ORACLE122 auto_deal]$ cat auto_clear_arch.sh
----------------------------------------------------------------------------------------------------
[oracle@ORACLE122 auto_deal]$ cat auto_clear_arch.sh
#!/bin/sh
ORACLE_SID=MPMON;
export ORACLE_SID
ORACLE_BASE=/u01/app/oracle;
export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/12.2.0/db_1;
export ORACLE_HOME
PATH=.:${JAVA_HOME}/bin:${PATH}:$HOME/bin:$ORACLE_HOME/bin:
PATH=${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin
export PATH
BACK_DIR=/home/oracle/auto_deal/data
export DATE=`date +%F`
mkdir -p $BACK_DIR/$DATE
echo "----------start------------------------" > $BACK_DIR/$DATE/rman_backup.log
#echo `date '+%Y-%m-%d %H:%M:%S'` >> $BACK_DIR/$DATE/rman_backup.log
$ORACLE_HOME/bin/rman log=$BACK_DIR/$DATE/rman_backup.log target / <
crosscheck archivelog all;
#删除无效归档
delete noprompt expired archivelog all;
#删除一天前的归档
#delete noprompt archivelog until time 'sysdate-1';
# delete force archivelog all completed before 'sysdate-1/24';
# 这里执行清除归档日志,如果不想手动输入YES,则可以添加noprompt参数
delete force noprompt archivelog all completed before 'sysdate-6';
#删除所有的归档
#delete nopromptarchivelogall;
exit;
EOF
echo "-----------end------------------------------" >> $BACK_DIR/$DATE/rman_backup.log
----------------------------------------------------------------------------------------------------
[oracle@ORACLE122 auto_deal]$ chmod +x auto_clear_arch.sh
【ORACLE|ORACLE 定时清理7天前归档日志】#每天早上5点运行 auto_clear_arch.sh
crontab –e
0 5 * * * /home/oracle/auto_deal/auto_clear_arch.sh
[oracle@ORACLE122 auto_deal]$ crontab -l
0 5 * * * /home/oracle/auto_deal/auto_clear_arch.sh
推荐阅读
- oracle|oracle java jdk install
- 15、IDEA学习系列之其他设置(生成javadoc、缓存和索引的清理等)
- linux定时任务contab
- 芯灵思SinlinxA33开发板Linux内核定时器编程
- 樊樊分享的扫除道
- 数据技术|一文了解Gauss数据库(开发历程、OLTP&OLAP特点、行式&列式存储,及与Oracle和AWS对比)
- STM32F4|STM32F4 TIM6 TIM7 基本定时器
- 无聊时
- 20180305|20180305 小确幸
- 闭包-定时器-BOM