签到成功

知道了

CNDBA社区CNDBA社区

删除Oracle Data Guard 备库归档文件 Python 脚本

2017-11-01 13:41 2635 0 原创 Oracle 18c Python Linux
作者: dave
[dave@www.cndba.cn scripts]$ ls
rman_del_arch.log  rman_del_arch.py
[dave@www.cndba.cn scripts]$ cat rman_del_arch.py 
#!/usr/bin/python
#coding=utf-8

import os
import sys
from subprocess import Popen,PIPE


def del_arch():
    cp = Popen(["rman","target","/"], stdout=PIPE, stdin=PIPE)
    cp.stdin.write("crosscheck archivelog all;" + os.linesep)
    cp.stdin.write("list expired archivelog all;  " + os.linesep)
    cp.stdin.write("delete noprompt archivelog all completed before 'sysdate-1';" + os.linesep)
    cp.stdin.write("exit;" + os.linesep)
    out, err = cp.communicate()
    print out.strip()

if __name__ == "__main__":
    del_arch()

#添加到linux 计划任务:
[dave@www.cndba.cn scripts]$ crontab -l
39 13 * * * source ~/.bash_profile; /usr/bin/python /u01/scripts/rman_del_arch.py > /u01/scripts/rman_del_arch.log 2>&1 &
[dave@www.cndba.cn scripts]$
http://www.cndba.cn/dave/article/2308 http://www.cndba.cn/dave/article/2308 http://www.cndba.cn/dave/article/2308 http://www.cndba.cn/dave/article/2308 http://www.cndba.cn/dave/article/2308
http://www.cndba.cn/dave/article/2308
http://www.cndba.cn/dave/article/2308
http://www.cndba.cn/dave/article/2308
http://www.cndba.cn/dave/article/2308 http://www.cndba.cn/dave/article/2308

版权声明:本文为博主原创文章,未经博主允许不得转载。

用户评论
* 以下用户言论只代表其个人观点,不代表CNDBA社区的观点或立场
dave

dave

关注

人的一生应该是这样度过的:当他回首往事的时候,他不会因为虚度年华而悔恨,也不会因为碌碌无为而羞耻;这样,在临死的时候,他就能够说:“我的整个生命和全部精力,都已经献给世界上最壮丽的事业....."

  • 2261
    原创
  • 3
    翻译
  • 578
    转载
  • 191
    评论
  • 访问:7970497次
  • 积分:4346
  • 等级:核心会员
  • 排名:第1名
精华文章
    最新问题
    查看更多+
    热门文章
      热门用户
      推荐用户
        Copyright © 2016 All Rights Reserved. Powered by CNDBA · 皖ICP备2022006297号-1·

        QQ交流群

        注册联系QQ