Sponsored Content
Top Forums Shell Programming and Scripting Kill idle script is killing unnecessarly Post 302400924 by methyl on Thursday 4th of March 2010 01:23:06 PM
Old 03-04-2010
Some areas where the script could go wrong:

1) If is run from cron too frequently runs could overlap.

2)
Quote:
who -u | /usr/xpg4/bin/grep -i -f $SELECTUSERS|/usr/xpg4/bin/awk '{print $1 "," $2 "," $6 "," $7}' > $USERSLOG
If one username is contained in another user name you could get a false match. e.g. "fred" and "alfred" . Depends on what your usernames are like.


3)
Quote:
PID=`ps -ef | /usr/xpg4/bin/grep "$PTS" | /usr/xpg4/bin/grep "pronto" | /usr/xpg4/bin/awk '{print $2}' | head -1`
Lots of scope for false mismatches. Consider similar PTS values "pts/aa" and "pts/aab" .
No point in running "ps -ef" because we already know $PTS. Try "ps -ft"${PTS}". This will make the script faster and reduce the chance of false matches.
Also the the second "grep" in the pipeline could find the first "grep" in the pipeline.

Could be better with something like this which allows for the user to log out since we started our script. Also reduces chance of false matches. I don't know whether the "head -1" is needed as I know nothing about your process table.

Quote:
ps -ft"${PTS}" 2>/dev/null | /usr/xpg4/bin/grep "pronto" | /usr/xpg4/bin/grep -v "grep" | /usr/xpg4/bin/awk '{print $2}' | head -1 | while read PID
do
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
done
I have never issued a "kill -5" but I assume that it means something to "pronto"?
 

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
update(n)						       Tcl Built-In Commands							 update(n)

__________________________________________________________________________________________________________________________________________________

NAME
update - Process pending events and idle callbacks SYNOPSIS
update ?idletasks? _________________________________________________________________ DESCRIPTION
This command is used to bring the application ``up to date'' by entering the event loop repeatedly until all pending events (including idle callbacks) have been processed. If the idletasks keyword is specified as an argument to the command, then no new events or errors are processed; only idle callbacks are invoked. This causes operations that are normally deferred, such as display updates and window layout calculations, to be performed imme- diately. The update idletasks command is useful in scripts where changes have been made to the application's state and you want those changes to appear on the display immediately, rather than waiting for the script to complete. Most display updates are performed as idle callbacks, so update idletasks will cause them to run. However, there are some kinds of updates that only happen in response to events, such as those triggered by window size changes; these updates will not occur in update idletasks. The update command with no options is useful in scripts where you are performing a long-running computation but you still want the applica- tion to respond to events such as user interactions; if you occasionally call update then user input will be processed during the next call to update. SEE ALSO
after(n), bgerror(n) KEYWORDS
event, flush, handler, idle, update Tcl 7.5 update(n)
All times are GMT -4. The time now is 11:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy