针对分区表一个月3个分区定期清理脚本

1.定时任务--当前月的前一个月的当前日期

05 20 1  * *  /bin/sh  /home/oracle/truncate_partition.sh &> /dev/null
05 20 11 * *  /bin/sh  /home/oracle/truncate_partition.sh &> /dev/null
05 20 21 * *  /bin/sh  /home/oracle/truncate_partition.sh &> /dev/null

[oracle@testglt]$ cat /home/oracle/truncate_partition.sh
#!/bin/bash

source /home/oracle/.bash_profile
sqlplus -s test/test@db>> /home/oracle//truncate_partition.log <<EOF
set feedback off heading off term off
set pages 1000 trim on trims on lines 32767 long 999999
set echo off
spool /home/oracle/truncate_partition_`date +%y%m%d`.sql
@/home/oracle//truncate_partition.sql
spool off
EOF

sqlplus sys/test@dbas sysdba  >> /home/oracle/exec_truncate_p.log <<EOF
@/home/oracle/truncate_partition_`date +%y%m%d`.sql
EOF

 

posted @   钱若梨花落  阅读(294)  评论(0编辑  收藏  举报
(评论功能已被禁用)
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
点击右上角即可分享
微信分享提示