Date: Tue, 18 Dec 2007 09:06:41 -0500
Reply-To: Michael Raithel <michaelraithel@WESTAT.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Michael Raithel <michaelraithel@WESTAT.COM>
Subject: Re: Remote Orphaned Sessions and SAS termination Scripts
In-Reply-To: <200712181129.lBHLrUPM024591@malibu.cc.uga.edu>
Content-Type: text/plain; charset="us-ascii"
Dear SAS-L-ers,
Tom Lolay posted the following:
> We're having a few issues with orphaned remote sessions
> staying on the server after a session has been closed. Hence
> the session work folder still remains on the server taking up space.
>
> I've been advised that a way to stop this happening is to
> issue the 'signoff' command followed by 'bye'.
>
> Is this true or is there a better way to do this?
>
> Also, if this is the case we wpould like to add these
> commands to a piece of script which runs automatically when
> SAS is closed down. Does anyojne know where the SAS execution
> script is stored?
>
> Any help would be gratefully appreciated as per usual. Also
> could you tick the box that sends me an email directly.
>
Tom, yea, we've had that problem here at SAS Mecca in the past, too. We
could not put our finger on exactly why it was happening, but think that
people who stopped their SAS sessions without issuing the SIGNOFF
command were responsible for the phenomena.
On the UNIX side of things, we implemented (cron-ed) a nightly SAS batch
program I wrote to kill these so called zombies. (They are really
"orphaned" sessions, but "killing zombies" sounds better than "killing
orphans")! Here is that program, in case you would like to implement
it:
************************************************************************
****
*;
* Program: killzombies.sas
*;
*
*;
* Author: Michael A. Raithel
*;
*
*;
* Created: 01/25/2002
*;
*
*;
* Purpose: This program checks the Unix system for zombies that were
created*;
* as a result of an abandoned SAS/Connect session from PC SAS.
*;
* If it finds any zombie sessions, it creates and executes Unix
*;
* "kill" commands to kill the zombies.
*;
*
*;
************************************************************************
****
*;
******************************************************************;
* Options, Includes, Formats, etc. *;
******************************************************************;
options source source2 msglevel=I;
******************************************************************;
* Unix PS command to find SAS/Connect zombies. *;
******************************************************************;
filename zombies pipe "ps -ef | grep sas | grep '?' | grep '[-]dmr
[-]comamid tcp [-]device grlink [-]noterminal'";
******************************************************************;
* Temporary file used to hold Unix kill commands. *;
******************************************************************;
filename zombtemp TEMP;
******************************************************************;
* Read in the piped Unix command, above, create SAS CALL SYSTEM *;
* statements that invoke the Unix "kill -9" command and store *;
* the statements in the ZOMBTEMP flatfile. *;
******************************************************************;
data _null_;
retain begin "call system('kill -9 "
end "');";
;
length bigline $32;
file zombtemp;
infile zombies missover length=length;
input userid $8.
pid $8.
;
bigline = begin || trim(left(pid)) || end;;
put bigline;
run;
******************************************************************;
* Include the ZOMBTEMP flatfile with the SAS CALL SYSTEM *;
* statements. They will be executed and kill the zombies. *;
******************************************************************;
data _null_;
%include zombtemp;
run;
In the program, above, I first pipe a 'ps -ef' with the proper 'grep'
for the zombie processes into the ZOMBIES filename. Then, I read the
'ps -ef | grep...' input in a data _null_ statement. That is where I
strip off the Process ID (PID) and create 'kill -9' Unix system commands
for each zombie process that I find. Those commands are hard-coded into
a SAS 'Call SYSTEM' statement, but I could have just as easily used the
SAS X command. I write the 'kill -9 ....' commands into a temporary
flat file named ZOMBTEMP. Finally, the ZOMBTEMP flat file is %INCLUDEd
into a data _null_ step, and thus executed--removing the zombie
processes from our Unix server.
The simple script file (that is executed at 2-hour intervals) is named
KILLZOMBIES_SCRIPT. It is marked as executable, and contains but a
single line of code:
/homedir/sas/sas /homedir/sas/utilities/bin/killzombies.sas
Our Unix administrator cron-ed the script. That was necessary because
he put it in a 'systems cron' so that it would have root authority when
it attempted to 'kill -9' the zombies. My own cron would not have had
such privileges, and the zombies would have laughed at my vain attempts
to put them to rest.
Tom, you should double-check to see if the 'grep' in the code, above, is
the right pattern to match a 'ps -ef' of your own zombie processes. You
wouldn't want healthy SAS/Connect processes to start disappearing at
2-hour intervals!
Also, our Unix administrator has cron-ed the cleanwork utility:
http://support.sas.com/onlinedoc/913/getDoc/en/hostunx.hlp/a000350996.ht
m
...for those SAS processes that just do not clean up after themselves.
Check it out!
Tom, best of luck in all of your SAS endeavors... on UNIX!
I hope that this suggestion proves helpful now, and in the future!
Of course, all of these opinions and insights are my own, and do not
reflect those of my organization or my associates. All SAS code and/or
methodologies specified in this posting are for illustrative purposes
only and no warranty is stated or implied as to their accuracy or
applicability. People deciding to use information in this posting do so
at their own risk.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Michael A. Raithel
"The man who wrote the book on performance"
E-mail: MichaelRaithel@westat.com
Author: Tuning SAS Applications in the MVS Environment
Author: Tuning SAS Applications in the OS/390 and z/OS Environments,
Second Edition
http://www.sas.com/apps/pubscat/bookdetails.jsp?catid=1&pc=58172
Author: The Complete Guide to SAS Indexes
http://www.sas.com/apps/pubscat/bookdetails.jsp?catid=1&pc=60409
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Anyone who lives within their means suffers from a lack of
imagination. - Oscar Wilde
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++