如何从 putty 中终止 oracle 数据库服务器上的进程 运行?
How to kill a process running on oracle db server from putty?
我在 PuTTY 中创建了一个 sql 文件,并使用以下命令将其保存在 运行 上:
sqlplus username/pwd@SSAR05 @exec_lmn_DELETE.sql > exec_lmn_DELETE_17102018.log &
我没有记下它的 SPID,但现在我想终止这个进程。
如何操作?
试试这个:
ps -ef| grep "sqlplus"
这应该会给您如下结果:
mayankp 30927 22295 0 Oct09 pts/22 00:00:02 /home/mayankp/anaconda2/bin/python /home/mayankp/anaconda2/bin/ipython
其中 30927
是进程 ID。杀之如:
kill -9 30927
我会说你必须先转到数据库并在那里终止会话。
由于在您当前的环境中可能有多个 SQL* Plus 会话,您将不知道要终止哪个进程。
首先从 ps 命令中识别进程 ID。
knayak-/Users/knayak-$ps -ef | grep [s]qlplus
501 23750 23309 0 11:46AM ttys004 0:00.05 sqlplus
501 23445 23309 0 11:50AM ttys004 0:00.05 sqlplus
如您所见,有多个 sqlplus 会话,您如何识别哪一个属于您?
连接到相关的数据库会话(最好是系统/dba 用户)
SELECT s.username,
s.sid,
s.osuser,
t.sql_id,
sql_text,
p.spid, -- OS Process id of the Oracle process
s.process . -- Client session process ID
FROM v$sqltext_with_newlines t JOIN
v$session s
ON t.address = s.sql_address AND t.hash_value = s.sql_hash_value
JOIN v$process p ON p.addr = s.paddr
WHERE s.status = 'ACTIVE' AND s.username <> 'SYSTEM'
AND sql_text LIKE '%DELETE%' --This should correspond to your statements in the sql file.
AND s.process IN ( '<list of pids from the command>') --put the client pids here.
ORDER BY s.sid,
t.piece;
现在,客户端 pid 与 Oracle 进程 的 PID 不同,运行正在执行此作业。
首先,杀掉底层的Oracle进程。当您在 Oracle 服务器中 运行 ps
并为从上面的查询中获得的 spid
进行 grep 时,您会看到类似的内容。
oracle 63063 1 32 23:16 ? 00:11:12 oracleSSAR05 (LOCAL=NO)
如果您无法访问Oracle 的登录,请让您的DBA 终止与此会话对应的会话。
然后终止相应的会话,如果它存在以 dba 身份连接到数据库。
ALTER SYSTEM KILL SESSION '<sid>,<serial#>'; -- from the query above
现在,检查客户端进程是否仍在 运行ning,它不应该。有的话最后杀掉。
我在 PuTTY 中创建了一个 sql 文件,并使用以下命令将其保存在 运行 上:
sqlplus username/pwd@SSAR05 @exec_lmn_DELETE.sql > exec_lmn_DELETE_17102018.log &
我没有记下它的 SPID,但现在我想终止这个进程。
如何操作?
试试这个:
ps -ef| grep "sqlplus"
这应该会给您如下结果:
mayankp 30927 22295 0 Oct09 pts/22 00:00:02 /home/mayankp/anaconda2/bin/python /home/mayankp/anaconda2/bin/ipython
其中 30927
是进程 ID。杀之如:
kill -9 30927
我会说你必须先转到数据库并在那里终止会话。
由于在您当前的环境中可能有多个 SQL* Plus 会话,您将不知道要终止哪个进程。
首先从 ps 命令中识别进程 ID。
knayak-/Users/knayak-$ps -ef | grep [s]qlplus
501 23750 23309 0 11:46AM ttys004 0:00.05 sqlplus
501 23445 23309 0 11:50AM ttys004 0:00.05 sqlplus
如您所见,有多个 sqlplus 会话,您如何识别哪一个属于您?
连接到相关的数据库会话(最好是系统/dba 用户)
SELECT s.username,
s.sid,
s.osuser,
t.sql_id,
sql_text,
p.spid, -- OS Process id of the Oracle process
s.process . -- Client session process ID
FROM v$sqltext_with_newlines t JOIN
v$session s
ON t.address = s.sql_address AND t.hash_value = s.sql_hash_value
JOIN v$process p ON p.addr = s.paddr
WHERE s.status = 'ACTIVE' AND s.username <> 'SYSTEM'
AND sql_text LIKE '%DELETE%' --This should correspond to your statements in the sql file.
AND s.process IN ( '<list of pids from the command>') --put the client pids here.
ORDER BY s.sid,
t.piece;
现在,客户端 pid 与 Oracle 进程 的 PID 不同,运行正在执行此作业。
首先,杀掉底层的Oracle进程。当您在 Oracle 服务器中 运行 ps
并为从上面的查询中获得的 spid
进行 grep 时,您会看到类似的内容。
oracle 63063 1 32 23:16 ? 00:11:12 oracleSSAR05 (LOCAL=NO)
如果您无法访问Oracle 的登录,请让您的DBA 终止与此会话对应的会话。
然后终止相应的会话,如果它存在以 dba 身份连接到数据库。
ALTER SYSTEM KILL SESSION '<sid>,<serial#>'; -- from the query above
现在,检查客户端进程是否仍在 运行ning,它不应该。有的话最后杀掉。