Read/kill processes

Hi,
I read a set of processes with:
ps -eaf|grep oracleTRLV

The result is:
oracle 23253 1 0 15:14:11 ? 0:00 oracleTRLV (LOCAL=NO)
oracle 23301 1 0 15:15:07 ? 0:00 oracleTRLV (LOCAL=NO)
oracle 22914 1 0 15:11:19 ? 0:00 oracleTRLV (LOCAL=NO)

How to I kill the "oracleTRLV" ones? Is there an option for the "kill" command that allows me to do it?

Thank you.

If you can logon as root or as the oracle user you can kill those processes. Assuming killing them is actually a good idea, which you should check on FIRST:

ps -eaf|grep oracleTRLV |  \ 
while read one pid restofline
do
     kill -9 $pid
done

You can try something like that :

ps -eaf | grep oracleTRLV | while read ora_proc
do
     set `echo $ora_proc`
     kill $2
done

:(Stupid question: how do I run the code provided?

You can run it directly from the shell prompt: just cut and paste

Beautiful ... thank you so much!!!

How do I run the code every 2 hours automatically?

Thank you!

First you need to save it as a script,

$ vi /directory/script_dir/your_script

Put that in your script:

#!/bin/ksh

ps -eaf|grep oracleTRLV |  \ 
while read one pid restofline
do
     kill -9 $pid
done

Use the crontab to schedule the task

$ crontab -e

Create an entry at the end of the file:
0 0,2,4,6,8,10,12,14,16,18,20,22 * * * /directory/script_dir/your_script > /tmp/your_script.log 2>&1

Thank you so much!!!

Is there a possibility to insert into the program a conditional kill? Let me explain:
1) The result of ps -eaf|grep oracleTRLV is:
oracle 17528 1 0 07:58:07 ? 0:01 oracleTRLV (LOCAL=NO)
oracle 18432 1 0 08:16:57 ? 0:00 oracleTRLV (LOCAL=NO)
oracle 18596 1 0 08:22:52 ? 0:00 oracleTRLV (LOCAL=NO)

2) If now is 8:00 AM can I kill just the processes that have a 7:00 AM (or earlier)?

3) Can you guys recommend a programming book? I assume that this is Shell programming? sorry I'm a .net programmer:(

Thank you.

Exemple of a basic conditionnal kill :

#!/bin/ksh

ps -eaf|grep oracleTRLV |  \ 
while read one pid dummy1 dummy2 time restofline
do
     hour=${time%"${time#??}"}
     current_hour=`date +%H`
     if [ $hour -lt $current_hour ]    # this is a very basic time comparison you can elaborate a more sophistaced one
     then
         kill -9 $pid
     fi
done

Found links for documentation here

Do you know a good shell programming book?

Thank you!

There are plently references here on the forum. Find some here

By a great forumer very active here:
Shell Scripting Recipes: A Problem Solution Approach -- C F A Johnson

1) I bought the book.

2) I was told that "vxfsd" is the program/process that suppose to clean automatically old processes in HP-Unix. Is this true?
The reason I'm asking is because after I reboot the server I can see my processes being cleaned/killed; however, after a day or so this "cleaning" doesn't work anymore. Any ideas?

Thank you.

Which book?

---
2)
vxfsd cleans vxfs inodes cache...
You could:

# kctune vxfs_ifree_timelag=-1

Here is where I get my knowledge from:
http://docs.hp.com/en/5992-0732/5992-0732.pdf

crontab

1) What book: Shell Scripting Recipes: A Problem-Solution Approach by Chris F.A. Johnson

2) Thank you for the link, I will take a look.

Thank you.