1、发变更让值班同事运行如下脚本
nohup sh ./spa.sh &
而spa.sh内容如下:
cat spa.sh
sqlplus ' / as sysdba' << eof
@POLICY_SPA.sql
exit;
eof
2、第二天上班来复核脚本,是否还在运行。
ps -ef | grep sqlplus | grep -v grep
opepcis 14431 13946 0 09:05:04 ? 1:59 sqlplus -s / as sysdba
opepcis 44610 44382 0 Jan 13 ? 0:01 sqlplus dbmon/
[email protected]:1530/monitor
opepcis 45336 19373 0 08:56:07 pts/3 0:00 sqlplus / as sysdba
opepcis 14850 1 0 23:08:21 ? 0:00 sqlplus / as sysdba
那假设,我们想看下pid为14850的执行sql语句,是否可行呢?
3、执行如下命令
09:21:57 sys@epcis>SELECT t.sql_fulltext FROM v$process p,v$session s,v$sql t
09:22:06 2 WHERE p.SPID=&1
09:22:12 3 AND p.ADDR=s.PADDR
09:22:16 4 AND t.sql_id=s.sql_id;
Enter value for 1: 14850
old 2: WHERE p.SPID=&1
new 2: WHERE p.SPID=14850
no rows selected
4、会不会是,产生了子进程?
通过子进程来查?
ps -ef | grep 14850 | grep -v grep
opepcis 14850 1 0 23:08:21 ? 0:00 sqlplus / as sysdba
opepcis 14851 14850 0 23:08:21 ? 88:57 oracleepcis (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
尝试查一下14851:
09:23:22 sys@epcis>SELECT t.sql_fulltext FROM v$process p,v$session s,v$sql t
WHERE p.SPID=14851
AND p.ADDR=s.PADDR
AND t.sql_id=s.sql_id;
SQL_FULLTEXT
--------------------------------------------------------------------------------
BEGIN
DBMS_SQLTUNE.CAPTURE_CURSOR_CACHE_SQLSET(SQLSET_NAME
=> 'STS_AUQIT07
OK能够查到,正在执行的语句了!