
www.Usenet.com
| <-- __Chronological__ --> | <-- __Thread__ --> |
Sybase 11.5.1, AIX 4.33
I am implementing an nightly batch job to kill user connections by
database. I plan to use a shell script that firstly produces a list of
spids using the following query
SELECT DISTINCT p.spid
FROM sysprocesses p,
syslogins l,
sysdatabases d,
syslocks o
WHERE p.suid = l.suid
AND p.dbid = d.dbid
AND o.spid = p.spid
AND l.name NOT IN ($EXCLUSION_LIST)
AND d.name = "$DATABASE"
where $EXCLUSION_LIST is a list of production logins.
After producing the list, I am looping through it killing the
processes one by one. If I get the 6106 (spid does not exist) or 6104
(trying to kill own spid), I will ignore the error. I test for 6104
because the originally identified spid could have terminated and the
spid I start to kill it might take its spid.
Does anyone have any thoughts on how this could be improved or if I
have missed anything obvious? I can't see a way to ensure that process
I have identified in the original query is the same as the one I am
killing. In the gap between identifying it and killing it, it could
have finished and another might take its spid. Ideally I would like to
be able to run it anytime, but with this weakness I can only run it
when production logins shouldn't be running.
These seems like a common task, but I can't find any examples on the
net.
| <-- __Chronological__ --> | <-- __Thread__ --> |