- 论坛徽章:
- 0
|
写个bash测试tnsping(加到crontab中),但是在脚本里执行的结果和在shell里执行的结果完全不一样
scripts
#!/bin/bash
oracle_home='/home/oracle'
oracle_base_home='/opt/oracle/product/10.2.0/db_1/bin'
my_date=`date +%Y-%m-%d_%H:%M:%S`
echo $my_date >> $oracle_home/tnspingtest.txt
$oracle_base_home/tnsping 172.17.1.8 >> $oracle_home/tnspingtest.txt
$oracle_base_home/tnsping 172.17.1.15 >> $oracle_home/tnspingtest.txt
echo '------------------------------------------------------------------' >> $oracle_home/tnspingtest.txt
脚本运行结果
2008-04-11_13:10:01
TNS Ping Utility for Linux: Version 11.1.0.6.0 - Production on 11-APR-2008 13:10:01
Copyright (c) 1997, 2007, Oracle. All rights reserved.
Message 3511 not found; No message file for product=network, facility=TNSMessage 3512 not found; No message file for product=network
, facility=TNSAttempting to contact (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=))(ADDRESS=(PROTOCOL=TCP)(HOST=172.17.1. (PORT=1521))(
ADDRESS=(PROTOCOL=TCP)(HOST=172.17.1. (PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=172.17.1. (PORT=1521)))
Message 3509 not found; No message file for product=network, facility=TNS
TNS Ping Utility for Linux: Version 11.1.0.6.0 - Production on 11-APR-2008 13:10:01
Copyright (c) 1997, 2007, Oracle. All rights reserved.
Message 3511 not found; No message file for product=network, facility=TNSMessage 3512 not found; No message file for product=network
, facility=TNSAttempting to contact (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=))(ADDRESS=(PROTOCOL=TCP)(HOST=172.17.1.15)(PORT=1521))
(ADDRESS=(PROTOCOL=TCP)(HOST=172.17.1.15)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=172.17.1.15)(PORT=1521)))
Message 3509 not found; No message file for product=network, facility=TNS
shell 执行结果
$ tnsping 172.17.1.8
TNS Ping Utility for Linux: Version 11.1.0.6.0 - Production on 11-APR-2008 14:07:26
Copyright (c) 1997, 2007, Oracle. All rights reserved.
Used parameter files:
Used HOSTNAME adapter to resolve the alias
Attempting to contact (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=))(ADDRESS=(PROTOCOL=TCP)(HOST=172.17.1. (PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=172.17.1. (PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=172.17.1. (PORT=1521)))
OK (30 msec)
$ tnsping 172.17.1.15
TNS Ping Utility for Linux: Version 11.1.0.6.0 - Production on 11-APR-2008 14:07:52
Copyright (c) 1997, 2007, Oracle. All rights reserved.
Used parameter files:
Used HOSTNAME adapter to resolve the alias
Attempting to contact (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=))(ADDRESS=(PROTOCOL=TCP)(HOST=172.17.1.15)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=172.17.1.15)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=172.17.1.15)(PORT=1521)))
OK (10 msec)
清DX们看看,这到底是因为什么导致的?
我的想法是要在脚本中添加有关ORACLE的环境变量。 |
|