Hi All,I have a problem with my kill idle script.my script is supposed to kill the user sessions which are idle for more than 2 hours.But is is killing the sessions which are idle for less than 2 hrs also.I dont know the exact time after which the script is killing,but it is less than 2 hours i am sure.I faced this problem personelly with my session also.i opened a new session of my application and after half an hour or so it got killed by the shell idle script.Here I am giving my kill idle script.Please if any one can make it out where the problem is that could be great.
#!/bin/sh
# This script will kill the users listed in the file $SELECTUSERS that are idle for the time equal to or greater then $IDLETIME. IDLETIME is in hours
. /run/pronto/lib/sh_environs
IDLETIME=2; export IDLETIME
# ERRORLOG=$PRONTO/lib/kill-idle/error.log; export ERRORLOG
KILLIDLELOG=$PRONTO/lib/kill-idle/kill-idle.log; export KILLIDLELOG
USERSLOG=$PRONTO/lib/kill-idle/users.log; export USERSLOG
SELECTUSERS=$PRONTO/lib/kill-idle/users; export SELECTUSERS
# below is for sunos
who -u | /usr/xpg4/bin/grep -i -f $SELECTUSERS|/usr/xpg4/bin/awk '{print $1 "," $2 "," $6 "," $7}' > $USERSLOG
for line in `cat "$USERSLOG"`
do
NAME=`echo $line | /usr/xpg4/bin/awk -F "," '{print $1}'`
PTS=`echo $line | /usr/xpg4/bin/awk -F "," '{print $2}'`
##Below is for hrs timeout
TIME=`echo $line | /usr/xpg4/bin/awk -F "," '{print $3}' | /usr/xpg4/bin/awk -F ":" '{print $1}'`
## Below is for minutes timeout
# TIME=`echo $line | /usr/xpg4/bin/awk -F "," '{print $3}' | /usr/xpg4/bin/awk -F ":" '{print $2}'`
if [ "$TIME" -ge "$IDLETIME" ]
then
echo `date` >> $KILLIDLELOG
echo "PTS = $PTS" >>$KILLIDLELOG
PID=`ps -ef | /usr/xpg4/bin/grep "$PTS" | /usr/xpg4/bin/grep "pronto" | /usr/xpg4/bin/awk '{print $2}' | head -1`
echo "PID is $PID" >>$KILLIDLELOG
echo "name is $NAME" >>$KILLIDLELOG
echo "Idle time is $TIME hrs" >>$KILLIDLELOG
echo "kill $PID" >>$KILLIDLELOG
echo "" >>$KILLIDLELOG
kill -5 $PID
fi
done
exit