midnight killin
Posted in 2006
This is IDS 9.4 UC2 on Windows 2000.
I do a dbexport at a site at 1:30 each morning after stopping various
services, etc. But UPS Worldship has a server running that keeps 2
connections open all the time. I try to kill them in a bat file and it
generally works. It uses onstat to output a file, then reads the file and
does onmode -z . Sometimes it does not work. I would prefer to use a C++
program to obtain the id's to kill.
I have searched the archives.
Has anyone got a select statement that will give the session id's for a
given "user"?
The .vbs file is below.
' Kills any db connection with "ups" in the name (case insensative).
' Informix environment must be set and you must be logged on as Informix.
' This script should be executed from a bat file that has set the
environment.
Const ForReading = 1
Const ForWriting = 2
Set Sh = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
qt = Chr(34) ' double quote
tokill = "ups fedex"
thefile = "upskill.txt"
cmdstring = "cmd /K onstat -g ses | findstr /I "
cmdstring = cmdstring & qt & tokill & qt & ">" & qt & thefile & qt
Sh.run cmdstring, 0, false ' do not wait cuz it hangs
giveup = true
kk = 0
do while kk < 200000
kk = kk + 1
for i = 1 to 100
cube = i^3
next
if fso.FileExists(thefile) then
giveup = false
exit do
end if
Loop
if giveup then
'MsgBox " giving up" , 64, "UPS Killer"
WScript.Quit
end if
' read the file
'id user tty pid hostname threads memory memory
explain
'106659 UPSred HPMX2131 3536 hpmx2131 1 397312 103536
off
Set pInFile = fso.OpenTextFile( thefile, ForReading, False)
died = 0
' MsgBox " start the killin" , 64, "UPS Killer"
do While not pInFile.AtEndOfStream
bigstring = pInFile.ReadLine()
if len(bigstring)=0 then exit do end if
' get the id and kill the informix session
stats = split(bigstring)
dbsess = stats(0)
' MsgBox dbsess, 64, "to kill"
Sh.run "onmode -z " & dbsess
died = died + 1
for i = 1 to 10000
cube = i^3
next
Loop
pInFile.Close
set Infile = nothing
set fso = nothing
WScript.Quit