>데이터 베이스 >MySQL 튜토리얼 >crontab对Oracle操作问题处理

crontab对Oracle操作问题处理

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB원래의
2016-06-07 17:19:17970검색

以上test.sh文件中必须设置ORACLE_HOME环境变量,否则加入到crontab 里不能正常执行(如把环境变量注释掉:#ORACLE_HOME=/oracle/

[root@localhost home]# vi test.sh
#!/bin/sh
Oracle_HOME=/oracle/ora10/product
export ORACLE_HOME
userpwd=test/test@10.11.0.235:1521/ora10g
$ORACLE_HOME/bin/sqlplus -S $userpwd alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';
INSERT INTO test values(1,'test');
COMMIT;
EOF
exit;
 
以上test.sh文件中必须设置ORACLE_HOME环境变量,否则加入到crontab 里不能正常执行(如把环境变量注释掉:#ORACLE_HOME=/oracle/ora10/product
#export ORACLE_HOME
),即使在sqlplus前加绝对路径/oracle/ora10/product/bin也不行,crontab文件如下test1_crond ,,日志见/var/log/cron

[root@localhost cron.d]# vi test1_crond
* * * * *  root sh /home/test.sh  >/home/test.log
~
~
SQL> conn test/test
Connected.
SQL> select * from test;
        ID NAME
---------- --------------------
         1 test
         1 test
         1 test
SQL>

[root@localhost cron.d]# tail -f /var/log/cron
Aug 17 14:03:01 localhost crond[10718]: (root) CMD (sh /home/x.sh)
Aug 17 14:03:01 localhost crond[10720]: (root) CMD (sh /home/test.sh  >/home/test.log)
Aug 17 14:04:01 localhost crond[11102]: (root) CMD (sh /home/x.sh)
Aug 17 14:04:01 localhost crond[11103]: (root) CMD (sh /home/test.sh  >/home/test.log)
Aug 17 14:05:01 localhost crond[11449]: (root) CMD (sh /home/x.sh)
Aug 17 14:05:01 localhost crond[11452]: (root) CMD (sh /home/test.sh  >/home/test.log)

linux

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.