LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 02-14-2006, 10:02 AM   #1
oulevon
Member
 
Registered: Feb 2001
Location: Boston, USA
Distribution: Slackware
Posts: 438

Rep: Reputation: 30
Shell-Script for killing processes


Hi,

I'm trying to kill several processes with a shell script. Right now I'm doing it manually with:

Code:
ps --user oulevon | grep process_name
I then kill the listed processes one by one. Is there a way to do it in a shell script? Thanks for any help?
 
Old 02-14-2006, 10:09 AM   #2
pypieuvre
LQ Newbie
 
Registered: Feb 2006
Location: Paris, France
Distribution: Ubuntu Breezy, Red Hat enterprise linux 3
Posts: 8

Rep: Reputation: 0
Do you know the command killall ?
by knowing the name you can do
Code:
killall myProcess
 
Old 02-14-2006, 10:16 AM   #3
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,499
Blog Entries: 2

Rep: Reputation: 68
kill `ps --user oulevon | grep process_name | awk '{print $2}'`

 
Old 02-14-2006, 10:23 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Also see pgrep/pkill (pkill -SIGNAL -U username -f processname).
 
Old 02-14-2006, 10:49 AM   #5
oulevon
Member
 
Registered: Feb 2001
Location: Boston, USA
Distribution: Slackware
Posts: 438

Original Poster
Rep: Reputation: 30
That did the trick. Thanks for all the help guys. I appreciate it.
 
  


Reply



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
Shell Scripting: Getting a pid and killing it via a shell script topcat Programming 15 10-28-2007 02:14 AM
Automating the "killing" process via a shell script fatrandy13 Linux - Software 5 09-13-2007 11:59 PM
shell script to kill processes running on port number varunbihani Linux - Newbie 13 12-06-2005 08:46 AM
shell script to read ps -e output and determine process double processes. dr_zayus69 Programming 1 09-21-2005 05:37 PM
shell script to kill all processes on specified port varunbihani Linux - General 1 04-19-2005 05:39 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:59 AM.

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