1.登录root
2.切换到ORACLE用户: #su – oracle
3.查看ORACLE环境变量是否有LD_LIBRARY_PATH变量,如果没有就添加如下:
查看环境变量: $cat ~/.bash_profile
添加环境变量: $vi ~/.bash_profile
随便哪行添加: export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
如下:
PATH=$PATH:$HOME/bin
… 省略..
export CAPAA_OWLET=/home/ora10g/setup/capaa-owlet/
export CAPAA_GOVERN=/home/ora10g/setup/capaa-govern/
export PATH=$PATH:$CAPAA_OWLET:$CAPAA_GOVERN
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
stty erase ^h
export PATH
退出保存: 按ESC然后按:x!最后回车即可
执行使之生效: $. ~/.bash_profile
查看是否生效: $echo $LD_LIBRARY_PATH
4.在$CAPAA_OWLET/capaa-owlet和$CAPAA_OWLET/script/capaa-owlet.ini两个文件的
#!/bin/bash下一行添加如下代码,用于获取ORACLE用户环境:
$vi $CAPAA_OWLET/capaa-owlet
#!/bin/bash
. ~/.bash_profile #添加的代码
$vi $CAPAA_OWLET/script/capaa-owlet.ini
#!/bin/bash
. ~/.bash_profile #添加的代码
然后退出编辑ESC,保存文本:x! 或者 :wq
5.先测试一下crontab是否能够成功重启capaa-owlet
$crontab -e
将 #*/1 * * * * /home/oracle/capaa_audit/capaa-owlet/capaaa-owlet restart
修改为 */1 * * * * /home/oracle/capaa_audit/capaa-owlet/capaaa-owlet restart >> /home/oracle/capaa_audit/capaa-owlet/log/restart.log 2>&1
注意: ‘#’符号被去掉, ESC , :x!保存!
6.重启内存审计
$capaa-owlet restart
查看进程: $ps -ef|grep capaa_owlet
若一分钟后,capaa_owlet进程不存在了说明脚本有问题;查看restart.log是否有错误信息
$tail -f $CAPAA_OWLET/log/restart.log
若出现类似于: “error while loading shared libraries: libclntsh.so.10.1: cannot open shared object file: No such file or directory”
则说明: LD_LIBRARY_PATH环境变量没有配置成功,需重新配置;
若出现类似于: :. /script
说明: 用户环境没有被加载到当前脚本,需要确认是否在$CAPAA_OWLET/capaa-owlet和$CAPAA_OWLET/script/capaa-owlet.ini两个文件#!/bin/bash,
的下一行,添加. ~/.bash_profile 并且保存;
一般这样添加成功了,crontab就能够成功执行定时重启进程;
7.观察 tail -f $CAPAA_OWLET/log/restart.log的执行结果,过个几分钟,若都出现类似于
stty: standard input: Invalid argument
Terminate capaa_owlet[27172]
Start capaa_owlet
stty: standard input: Invalid argument
Checking Oracle status Ok! database opened successful!
2596226964 XE 1
说明crontab成功执行了,这时候就需要将:
*/1 * * * * /home/oracle/capaa_audit/capaa-owlet/capaaa-owlet restart >> /home/oracle/capaa_audit/capaa-owlet/log/restart.log 2>&1
注释掉用’#',或者直接删除(鼠标移动到该行,然后 dd 这样就删除了),且去掉
#59 23 * * * /home/oracle/capaa_audit/capaa-owlet/capaaa-owlet restart 前面的’#',并在后面追加如下内容;
59 23 * * * /home/oracle/capaa_audit/capaa-owlet/capaaa-owlet restart >> /home/oracle/capaa_audit/capaa-owlet/log/restart.log 2>&1
ESC :x!保存一下

—这样就Ok了!

总结:
crontab是在root环境下执行的,非root用户在使用crontab时,必须在启动脚本中假如当前用户的环境变量,例如:本文中添加的 . ~/.bash_profile 就是用来获取oracle用户的环境;




Related posts

coded by nessus
分享:  DeliciousGReader鲜果豆瓣CSDN网摘
Trackback

only 1 comment untill now

  1. lairs@furs.tabula” rel=”nofollow”>.…

    ñïàñèáî çà èíôó….

Add your comment now

无觅相关文章插件