Kill IDLE Process using script !!!


 
Thread Tools Search this Thread
Operating Systems AIX Kill IDLE Process using script !!!
# 1  
Old 11-18-2009
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 :

Code:
root@bagpuss $ ps auxw|sort -r +3|head -10
USER      PID   %CPU  %MEM   SZ  RSS    TTY STAT  STIME  TIME   COMMAND
sharon   1658958  0.1  9.0 218016 214804 - A      Sep 13 38:16 db2agent (idle) 0
dpf      1036486  0.0  1.0 14376 14068   - A      Sep 17  3:10 db2hmon 0
sharon   1822932  0.0  1.0 12196 11608   - A      Sep 12  6:41 db2hmon 0
dpf      1011760  0.0  0.0 9264  9060    - A      Sep 17  3:03 db2hmon 3
dpf      1532116  0.0  0.0 9264  9020    - A      Sep 17  3:04 db2hmon 2
dpf       786672  0.0  0.0 9264  8984    - A      Sep 17  3:02 db2hmon 5
dpf      1077470  0.0  0.0 9264  8968    - A      Sep 17  3:03 db2hmon 1
dpf      1269798  0.0  0.0 9248  9044    - A      Sep 17  2:50 db2hmon 4
db2inst1  454756  0.0  0.0 9012  7120    - A      Jul 19  0:52 db2sysc 0


Now , I want to create a script which helps me to find out the IDLE process and Kill that process automatically using PID.

Would anybody help me to give a sample script to do it ?

I am grateful to you . Waiting for Kind reply ... ....

Last edited by pludi; 11-18-2009 at 03:24 PM.. Reason: code tags, please...
# 2  
Old 11-19-2009
Code:
while true do
sleep 30
ps auxw |grep idle  | kill `awk ' { print $2}'`
done
exit 0

every 30 second the script will check any idle process and kill it

it's maybe ok for you :-)

---------- Post updated 11-19-09 at 05:10 AM ---------- Previous update was 11-18-09 at 01:54 PM ----------


Last edited by pludi; 11-18-2009 at 03:24 PM.. Reason: code tags, please...
# 3  
Old 11-19-2009
Quote:
Originally Posted by wwwzviadi
Code:
while true do
sleep 30
ps auxw |grep idle  | kill `awk ' { print $2}'`
done
exit 0

every 30 second the script will check any idle process and kill it

it's maybe ok for you :-)

---------- Post updated 11-19-09 at 05:10 AM ---------- Previous update was 11-18-09 at 01:54 PM ----------

There might be some issues in this, will try to kill itself...
and what if more than one process are idle...you may get issues...

Actually there is no way we can check our script...

Try:
Code:
ps auxw | awk '/idle/&&!/awk/ {print $2}' | xargs -t -I {} kill -9 {}

Put the above in the loop given by zviadi
# 4  
Old 11-19-2009
Quote:
There might be some issues in this, will try to kill itself...
No this script will try to kill itself after all others are killed.. I have checked and it worked.. Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Idle command to kill the process running n unx box machine

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

2. 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

3. 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

4. UNIX for Dummies Questions & Answers

Script to start background process and then kill process

What I need to learn is how to use a script that launches background processes, and then kills those processes as needed. The script successfully launches the script. But how do I check to see if the job exists before I kill it? I know my problem is mostly failure to understand parameter... (4 Replies)
Discussion started by: holocene
4 Replies

5. Shell Programming and Scripting

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... (3 Replies)
Discussion started by: prabhu_kumar
3 Replies

6. Shell Programming and Scripting

Shell Script to Kill Process(number of process) Unix/Solaris

Hi Experts, we do have a shell script for Unix Solaris, which will kill all the process manullay, it used to work in my previous env, but now it is throwing this error.. could some one please help me to resolve it This is how we execute the script (and this is the requirement) ... (2 Replies)
Discussion started by: jonnyvic
2 Replies

7. Shell Programming and Scripting

How to kill process after x idle min?

I need a script to kill those process id whose idle time is more than 30min plz help me (3 Replies)
Discussion started by: salil2012
3 Replies

8. 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

9. 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

10. SCO

Identifiy and Kill Idle Unix(SCO) Process called externally

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
Login or Register to Ask a Question