Good afternoon
I need to KILL a process in a single command sentence, for example:
kill -9 `ps -aef | grep 'CAL255.4ge' | grep -v grep | awk '{print $2}'`
That sentence Kills the process ID corresponding to the program CAL255.4ge.
However it is possible that the same program CAL255.4ge is executed by 2 different users ID, for example:
/nfs/nfs3/fuentes/per>bgr
Procesos ejecutandose en este momento
-------------------------------------
usuario id hora proceso cola code inst
wilruiz0 401506 16:13:07 CAL224.4ge 203 Vid
wilruiz0 770282 16:16:49 CAL227.4ge 203 Gen
wilruiz0 880676 16:16:51 CAL255.4ge 203 Gen
wilruiz0 995572 16:16:47 CAL224.4ge 203 Gen
wilruiz0 1122314 16:16:37 CAL271.4ge 203 Gen
wilruiz0 1224878 16:13:10 CAL227.4ge 203 Vid
/nfs/nfs3/fuentes/per>ps -aef | grep wilruiz2
wilruiz2 385238 1204422 0 12:37:59 pts/28 0:00 -ksh
wilruiz2 401506 1 6 16:13:07 pts/28 0:05 CAL224.4ge 92793345 203
wilruiz2 880696 1 7 16:16:51 pts/11 0:01 CAL255.4ge 92793345 203
wilruiz2 634998 1073300 0 16:12:58 pts/28 0:00 CAR_main.4ge
wilruiz2 1073300 385238 0 16:12:43 pts/28 0:00 INSUNIX.4ge
wilruiz2 1224878 1 3 16:13:10 pts/28 0:03 CAL227.4ge 92793345 203
/nfs/nfs3/fuentes/per>ps -aef | grep wilruiz0
wilruiz0 602116 733346 1 16:27:54 pts/11 0:00 grep wilruiz0
wilruiz0 733346 798882 1 12:37:33 pts/11 0:00 -ksh
wilruiz0 770282 1 8 16:16:49 pts/11 0:01 CAL227.4ge 92793345 203
wilruiz0 844006 733346 22 16:27:53 pts/11 0:00 ps -aef
wilruiz0 880676 1 7 16:16:51 pts/11 0:01 CAL255.4ge 92793345 203
wilruiz0 995572 1 11 16:16:47 pts/11 0:02 CAL224.4ge 92793345 203
wilruiz0 1122314 1 43 16:16:37 pts/11 0:12 CAL271.4ge 92793345 203
There are 2 users
wilruiz0
and
wilruiz2
So I need to tell the UNIX to KILL the process, specifying both the PROGRAM NAME and the USERID.
I guess that would mean to improve the GREP sentence to search for 2 string patterns instead of one.
That would be:
kill -9 `ps -aef | grep -i -e 'CAL255.4ge' -e 'wilruiz0' | grep -v grep | awk '{print $2}'`
It is not working because it is searching for the patterns as an OR instead of AND where the 2 strings patterns are needed to meet.
Please help.