dbTalk Databases Forums  

Automated job to kill user connections

comp.databases.sybase comp.databases.sybase


Discuss Automated job to kill user connections in the comp.databases.sybase forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Thomas Richards
 
Posts: n/a

Default Automated job to kill user connections - 11-18-2003 , 09:23 AM






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.

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.