Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem killing off users

Status
Not open for further replies.

LeeHagen

IS-IT--Management
Sep 20, 2002
22
0
0
US
We use a script to kill off certain users before we start our nightly backup. We have installed AIX 5.2 on several servers and we are seeing that when a user's shell is killed off, the who command still sees the users as being logged on. We installed maintenace level 1 and are still seeing the same problem. We are now having the same problem on AIX 5.1 now that we installed maintenance level 4. Is anyone else experiencing this same problem?

Regards,

Lee Hagen
 
Hi
I suspect erroneous script you are using!can you please
post the script over here for checking.

sushveer
IBM certified specialist-p-series AIX5L System Administration
AIX/SOLARIS/WEBSPHERE-MQ/TIVOLI Administrator
 
This script works just fine on 5.1 maintenance level 3 and under. Something changed on 5.2 and 5.1 maintenance level 4. The user processes are successfully killed off by the script. The who command just doesn't immediately acknowledge it with the new AIX levels. Eventually all the users show up as being logged off by the who command but it takes up to an hour for this to happen where on the older levels of AIX it happened immediately. This causes a problem for us since we varify that all the unprotected users are actually logged off before we kick off the backup script. We are getting false information that the users are still logged in even though they actually aren't. Here is the script anyways. Maybe you can think of a alternate method of killing of the users instead of killing off their shell.

!/bin/ksh
#
# Created by: Lee Hagen
# Create date: 01/18/2003
# Function: Script to kill off unprotected users
#
###################################################################################################
echo "`who am i | awk '{ print $1 }'` `date`" > /isdept/logs/killallusers.log
clear
echo ""
echo ""
who -u > /isdept/tmp/killallusers.txt
exec < /isdept/tmp/killallusers.txt
while read LINE
do
USER=&quot;`echo $LINE | awk '{ print $1 }'`&quot;
if [[ $USER = &quot;root&quot; || $USER = &quot;bernhc&quot; || $USER = &quot;carpem&quot; || $USER = &quot;nealam&quot; || $USER = &quot;donagm&quot; ]]
then
echo &quot;$USER is a protected user, the processes for this user will not be killed off&quot;
else
echo &quot;The process ID for $USER will now be killed off&quot;
PROCID=&quot;`echo $LINE | awk '{ print $7 }'`&quot;
PROCIDPARENT=&quot;`ps -ef | grep $PROCID | grep -v grep | awk '{ print $3 }'`&quot;
echo &quot;Killing $PROCIDPARENT $PROCID process ids for $USER&quot; >> /isdept/logs/killallusers.log
echo &quot;Killing $PROCIDPARENT $PROCID process ids for $USER&quot;
kill $PROCIDPARENT $PROCID
fi
done
rm /isdept/tmp/killallusers.txt
chmod 644 /isdept/logs/killallusers.log
 
To further explain the problem, the /etc/utmp file is no longer getting immediately updated when users shells are killed off like they were in 5.1 maintenance level 3 and below.
 
Can you please try with this:

#fuser -kux /mnt

also check with
#lsof /mnt

find out the users accessing the specific fs and kill those processes .
#kill -9 <procid>

This is just an alternative for trouble shooting ...

sushveer
IBM certified specialist-p-series AIX5L System Administration
AIX/SOLARIS/WEBSPHERE-MQ/TIVOLI Administrator
 
We use a script prior to doing maintenance on our servers. We have to manually input the user names but you could change this to use an input file. We have been using this script for years now. We are on AIX 4.3.3 ML10 but see if this might help you out. This is for Oracle processes but I am sure you could adapt it for your use.
Hope this helps.


#!/bin/ksh
clear
FILE=/tmp/safe.$$
PIDSFORKILL=/tmp/pids.$$
AUTHUSE=`whoami`
CRITERIA=&quot;root|ora_&quot;

#Sets TEXT1 to be a search string

if [ $# = 0 ]; then
echo &quot;\nUsage: $0 {text}&quot;
exit 1
else
TEXT1=$1
fi

ps -ef | grep $TEXT1 | egrep -v &quot;$0|grep&quot; > $FILE

if [ `wc -l $FILE | awk '{ print $1 }'` = 0 ]; then
echo &quot;\nThere are no processes that match $TEXT&quot;
exit
fi
more $FILE

echo &quot;\nDo you want to kill the above processes? (y/n)&quot;

read ANSWER

if [ $ANSWER = y ]; then
if [ $AUTHUSE = root ]; then
cat $FILE | awk '{ print $2 }' >$PIDSFORKILL
SAFEPIDS=&quot;`cat $PIDSFORKILL`&quot;
for pid in $SAFEPIDS
do
print &quot;Killing process id:&quot; $pid
kill -9 $pid
done
else
egrep -q &quot;$CRITERIA&quot; $FILE
RC=$?
if [[ $RC = 0 ]]; then
print &quot;The following processes cannot be killed because they are o
wned by root or they are an Oracle database process:\n&quot;
egrep &quot;$CRITERIA&quot; $FILE
print &quot;\n&quot;
fi
egrep -v &quot;$CRITERIA&quot; $FILE | awk '{ print $2 }' > $PIDSFORKILL
SAFEPIDS=&quot;`cat $PIDSFORKILL`&quot;
for pid in $SAFEPIDS
do
print &quot;Killing process id:&quot; $pid
/usr/local/bin/killproc $pid
done
fi
fi
rm -f $FILE
rm -f $PIDSFORKILL
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top