02-24-2009
[[ -z "$1" ]] && echo "Usage: $0 pid" && exit 1
[[ "$1" != +([0-9]) ]] && echo "$1 is not a valid pid" && exit 1
PID="$1"
W=$(which w)
PS=$(which ps)
SED=$(which sed)
AWK=$(which awk)
TTY=$($PS -o tty4 $PID)
TTNo=$(echo "$TTY" | $SED -e '/TTY/d')
TIME=$($W | $SED -n -e "/pts\/$TTNo/p" | $AWK '{ print $5 }')
echo $PID has been idle for $TIME
[[ $TIME = *day* ]] && echo "Killing $PID" && kill -9 $PID && exit 0
IDLE=${TIME%%:*}
[[ $IDLE -gt 30 ]] && echo "Killing $PID" && kill -9 $PID && exit 0
it doesn't work.....
10 More Discussions You Might Find Interesting
1. SCO
Hi,
Please let us know of any possiblity of identifying and killing unix proces invoked externally (by an external tool which does not create a session). 'who' command gives idle time of sessions. But what we are looking for is idle time of a process. 'ps' command gives the elapsed/running... (1 Reply)
Discussion started by: vbalajis
1 Replies
2. HP-UX
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
3. HP-UX
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
4. Shell Programming and Scripting
From a perl script , How can I monitor a PS which I activated and kill it within 5 minutes in case it didn't complete its tasks.:confused: (2 Replies)
Discussion started by: Alalush
2 Replies
5. AIX
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
6. Solaris
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
7. Shell Programming and Scripting
Folks,
I have written one script for following condition by referring some of online post in this forum. Please correct it if I'm missing something in it. (OS: AIX 5.3)
List the idle user. (I used whoidle command to list first 15 user and get username, idle time, pid and login time).... (4 Replies)
Discussion started by: sumit30
4 Replies
8. Shell Programming and Scripting
Hello..
I have many sleepy users on my Solaris box and need to kill them if they are idle for more than 45 minutes for example...I know who -u gives and the idle time but unable to make a awk line to get the condition perfect. Please help...:wall: (9 Replies)
Discussion started by: wimaxpole
9 Replies
9. Shell Programming and Scripting
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 Beginners Questions & Answers
Hi Team ,
I have one process named as cec_analysiseool that is running on unix box machine now i want to kill this process so please advise what will be the ideal command to kill this , what i have tried is :confused:
kill -9 `ps -ef | grep cec_analysiseool | grep -v grep | awk '{print $2}'` (2 Replies)
Discussion started by: unclesamm
2 Replies
AXCTL(8) Linux System Managers Manual AXCTL(8)
NAME
axctl - Configure/Kill running AX.25 connections.
SYNOPSIS
axctl [-v] port dest src window|t1|t2|t3|n2|idle|paclen|kill [parm]
DESCRIPTION
The axctl command is designed to be a multi-function command that allows miscellaneous commands to be issued to the Linux AX.25 protocol
layer for existing AX.25 connections. The connection is uniquely identified via the combination of port, destination callsign and source
callsign, with that information the kernel is able to change the parameters, or abort the connection.
Many of the options are similar to those found in axparms and perform the same function. Only one parameter may be changed on each invoka-
tion of axctl.
OPTIONS
-v Displays the version number.
window window Sets the window size for the AX.25 connection.
t1 t1-timeout Sets the initial T1 timeout value for the AX.25 connection, the value is given in seconds.
t2 t2-timeout Sets the T2 timeout value for the AX.25 connection, the value is given in seconds.
t3 t3-timeout Sets the T3 timeout value for the AX.25 connected, the value is given in seconds.
n2 n2-count Sets the maximum number of tries for the AX.25 connection.
idle idle-timeout Sets the value for the idle timer for the AX.25 connection, the value is in minutes.
paclen paclength Sets the maximum packet length that may be transmitted on the AX.25 connection.
kill Will abort an existing AX.25 connection.
FILES
/etc/ax25/axports
SEE ALSO
call(1), getsockopt(2), setsockopt(2), ax25(4), axparms(8), axports(5).
AUTHORS
Joerg Reuter DL1BKE <jreuter@poboxes.com>
Linux 2 August 1996 AXCTL(8)