LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   script to delete some processes (https://www.linuxquestions.org/questions/programming-9/script-to-delete-some-processes-606747/)

Carlos2dub 12-14-2007 08:36 AM

script to delete some processes
 
Hello,

I need to develop a script to kill some processes by name, killall is not working for me. What I was doing was to search the name in the list of all processes and then get jobid to kill the process one by one but doesnt work, because the grep of this machine(debian 2001) doesnt have the -m option. And I cannot upgrade the operative system cause it runs critical processes...

I will appreciate any idea of how to do this in a different way. My knowledge of bash is not too advanced :(

Cheers,
Carlos.

#! /bin/bash

# Stop all doors processes

NLINEA=2
JOBID=1
TOTAL=1


ps -ef | grep -i doors > /home/carlos/file
TOTAL=`wc -l /home/carlos/file | cut -c 6-7`
echo $TOTAL

while [ $NLINEA -lt $TOTAL ]

do
ps -ef | grep doors -m $NLINEA > /home/carlos/file
NLINEA=`expr $NLINEA + 1`
JOBID=`tail -n 1 file | cut -c 10-14`

# kill -9 $JOBID
echo "process $JOBID killed"
done

nc3b 12-14-2007 09:18 AM

http://www.linuxquestions.org/questi...-linux-605141/


All times are GMT -5. The time now is 03:31 PM.