Sponsored Content
Top Forums Shell Programming and Scripting Kill idle script is killing unnecessarly Post 302400800 by prabhu_kumar on Thursday 4th of March 2010 06:32:50 AM
Old 03-04-2010
Question Kill idle script is killing unnecessarly

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.

Code:
#!/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


Last edited by pludi; 03-04-2010 at 08:00 AM.. Reason: code tags, please...
 

10 More Discussions You Might Find Interesting

1. Cybersecurity

Killing Idle session

does any one know how to kill an idle session? I want to kill any idle sessions after 30 min... Local or remote.... i want to do this without a script or TCP wrappers...i want to know if there is a file that i can configure..... ThAnks:rolleyes: (4 Replies)
Discussion started by: securhack
4 Replies

2. UNIX for Dummies Questions & Answers

Killing idle user processes

I'm looking for some help, please! I'm trying to kill any idle user processes over 40 Minutes. I have tried putting TMOUT=2400 within the users .profile However this does not seem to be working. We run aix 4.3.3 with ORACLE 7.3 The above works o.k. when the user is only within the... (3 Replies)
Discussion started by: annette
3 Replies

3. HP-UX

Is there a script available to kill Idle users

My max user parm is set to 1050. I'm currently at 1038 this is causing major slow downs on the server. I looking for a way log off "idle" user logins with out having to do it individually. :confused: (5 Replies)
Discussion started by: rfmurphy_6
5 Replies

4. Shell Programming and Scripting

script for killing idle users

I need a script that will look for idle users and kill there proc. (7 Replies)
Discussion started by: jdel80
7 Replies

5. Shell Programming and Scripting

Killing idle users TIA

I wrote a script to kill users idle more than 1/2 hour, ignoring those in an exception list. Here is the script as it is now: #! /usr/bin/awk -f BEGIN { system("who -u | sort +5 > /tmp/loginfile"); system("echo User Sessions Killed > /tmp/killedlogins"); ... (2 Replies)
Discussion started by: PapaBear
2 Replies

6. HP-UX

kill idle users

Hi, In my network we uses the NetTerm program to connect us to HP-UX 10.x server from windows workstations, but in some cases the user doesn't logout and close it by window's x button. The problem is that in HP-UX the user and all his tasks remain active and when he enter again HP-UX creates a... (12 Replies)
Discussion started by: efrenba
12 Replies

7. AIX

Kill IDLE Process using script !!!

Dear Friends , I am using DB2 database in AIX 5.3 server . In my server some IDLE process are generated after several times which I need to kill it manually each and every time . The process I query like following : root@bagpuss $ ps auxw|sort -r +3|head -10 USER PID %CPU %MEM ... (3 Replies)
Discussion started by: shipon_97
3 Replies

8. Solaris

Kill idle dt session

Hi, i need to kill the idle dt sessions through script, can anyone tell me how to do? RJS (2 Replies)
Discussion started by: rajasekg
2 Replies

9. Shell Programming and Scripting

Kill idle Process using a script

Hi, I need a script that can automatically kill all processes named "webrepn" and "webrebw" if idle for more than 30 minutes. Then I will have a Cron Job to run the script every night or 2-3 times a day depends on how this script helps. Right now, I run "ps -ef | grep webrebn" and "kill -9... (7 Replies)
Discussion started by: MaggieL
7 Replies

10. UNIX for Advanced & Expert Users

Trapping a kill command sent to a script and using it to send an EOF to a subprocess before killing

I originally had a script written in pure shell that I used to parse logs in real time and create a pipe delimited file that only contained errors. It worked but it was using a lot of memory (still not clear on why). I originally got around this by writing a wrapper for the script that ran on cron... (1 Reply)
Discussion started by: DeCoTwc
1 Replies
IDLE(1) 						      General Commands Manual							   IDLE(1)

NAME
IDLE - An Integrated DeveLopment Environment for Python SYNTAX
idle [ -dins ] [ -t title ] [ file ...] idle [ -dins ] [ -t title ] ( -c cmd | -r file ) [ arg ...] idle [ -dins ] [ -t title ] - [ arg ...] DESCRIPTION
This manual page documents briefly the idle command. This manual page was written for Debian because the original program does not have a manual page. For more information, refer to IDLE's help menu. IDLE is an Integrated DeveLopment Environment for Python. IDLE is based on Tkinter, Python's bindings to the Tk widget set. Features are 100% pure Python, multi-windows with multiple undo and Python colorizing, a Python shell window subclass, a debugger. IDLE is cross-plat- form, i.e. it works on all platforms where Tk is installed. OPTIONS
-h Print this help message and exit. -n Run IDLE without a subprocess (see Help/IDLE Help for details). The following options will override the IDLE 'settings' configuration: -e Open an edit window. -i Open a shell window. The following options imply -i and will open a shell: -c cmd Run the command in a shell, or -r file Run script from file. -d Enable the debugger. -s Run $IDLESTARTUP or $PYTHONSTARTUP before anything else. -t title Set title of shell window. A default edit window will be bypassed when -c, -r, or - are used. [arg]* and [file]* are passed to the command (-c) or script (-r) in sys.argv[1:]. EXAMPLES
idle Open an edit window or shell depending on IDLE's configuration. idle foo.py foobar.py Edit the files, also open a shell if configured to start with shell. idle -est "Baz" foo.py Run $IDLESTARTUP or $PYTHONSTARTUP, edit foo.py, and open a shell window with the title "Baz". idle -c "import sys; print sys.argv" "foo" Open a shell window and run the command, passing "-c" in sys.argv[0] and "foo" in sys.argv[1]. idle -d -s -r foo.py "Hello World" Open a shell window, run a startup script, enable the debugger, and run foo.py, passing "foo.py" in sys.argv[0] and "Hello World" in sys.argv[1]. echo "import sys; print sys.argv" | idle - "foobar" Open a shell window, run the script piped in, passing '' in sys.argv[0] and "foobar" in sys.argv[1]. SEE ALSO
python(1). AUTHORS
Various. 21 September 2004 IDLE(1)
All times are GMT -4. The time now is 08:32 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy