[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]$
版权声明:本文为博主原创文章,未经博主允许不得转载。
- 上一篇:那个从来不加班的年轻人后来过得怎么样?
- 下一篇:100句 传统谚语 遇上 英文