- [root@hzvscmdb sql]# more check_connect_oracle.sh
- #!/bin/bash
- #functions: connect oracle server test
- #author:Tony Wang
- #modify_date: 2015-06-03.
- mkdir -p /home/tony/shell/sql/log #create the directory of log
- LOG_DIR=/home/tony/shell/sql/log #log path
- rm -rf $LOG_DIR/* #delete the expire log
- USERNAME=hr #user
- PASSWORD=pass #password
- SIDNAME=tony1521 #TNS
- icount=0
- while [ "$icount" -lt 20 ]
- do
- {
- count=0
- while [ "$count" -lt 10 ]
- do
- LOG_FILE=$LOG_DIR/check_oracle_$icount.$count.log
- echo `sqlplus $USERNAME/$PASSWORD@$SIDNAME << EOF
- set echo off
- set feedback off
- spool $LOG_FILE
- alter session set nls_date_format='YYYY-MM-DD:HH24:MI:SS';
- select sysdate from dual;
- spool off
- set echo on
- set feedback on
- exit
- EOF` >> $LOG_FILE
- let count=$count+1
- done
- } &
- let icount=$icount+1
- done
- --该片段来自于http://www.codesnippet.cn/detail/0806201512792.html
来源: http://www.codesnippet.cn/detail/0806201512792.html