Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 12-14-2007, 09:36 AM   #1
LQ Newbie
Registered: Aug 2007
Location: Madrid
Distribution: Debian 4, openSUSE 10.3, RHEL 5
Posts: 24

Rep: Reputation: 15
script to delete some processes


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


#! /bin/bash

# Stop all doors processes


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

while [ $NLINEA -lt $TOTAL ]

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"


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
can you do threading or multiple processes in a shell script? BrianK Programming 8 08-07-2006 05:40 PM
script to kill processes tradnbillies Linux - Software 2 04-28-2006 04:00 PM
Shell-Script for killing processes oulevon Programming 4 02-14-2006 11:49 AM
Priority of processes (using nice) started from within a script podollb Linux - Software 1 01-08-2006 12:44 PM
shell script to kill all processes on specified port varunbihani Linux - General 1 04-19-2005 06:39 AM > Forums > Non-*NIX Forums > Programming

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

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration