LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-27-2005, 11:16 AM   #1
mijohnst
Member
 
Registered: Nov 2003
Location: Huntsville, AL
Distribution: RHEL, Solaris, OSX, SuSE
Posts: 419

Rep: Reputation: 31
Killing process by username


So if I want to kill a process I type 'ps -aux' then find the process number and then use 'kill -9 processnumber. What if I want to kill something by the username?

So I type 'ps -aux | grep mijohnst' to find out what I'm running. if I have a hundred processeds, how do I just tell it to kill everything that mijohnst is running?
 
Old 05-27-2005, 11:23 AM   #2
perfect_circle
Senior Member
 
Registered: Oct 2004
Location: Athens, Greece
Distribution: Slackware, arch
Posts: 1,783

Rep: Reputation: 53
Code:
for proc_num in `ps -U <username> | cut -f1 -d" "`; do kill -9 $proc_num; done
 
Old 05-27-2005, 11:57 AM   #3
mijohnst
Member
 
Registered: Nov 2003
Location: Huntsville, AL
Distribution: RHEL, Solaris, OSX, SuSE
Posts: 419

Original Poster
Rep: Reputation: 31
Thanks Pefect_Circle!
 
Old 05-29-2005, 09:39 PM   #4
perfect_circle
Senior Member
 
Registered: Oct 2004
Location: Athens, Greece
Distribution: Slackware, arch
Posts: 1,783

Rep: Reputation: 53
there is also a command to do this I wasn't aware of.
The command is skill.
Code:
skill -u <username>
will send a TERM signal to all processes whose owner is username
SO
Code:
skill -9 -u <username>
will send a KILL signal.
Try:
Code:
man skill
for more info
 
Old 05-30-2005, 08:50 PM   #5
mijohnst
Member
 
Registered: Nov 2003
Location: Huntsville, AL
Distribution: RHEL, Solaris, OSX, SuSE
Posts: 419

Original Poster
Rep: Reputation: 31
Wow, that's even better. Thanks for coming back and posting this.
 
  


Reply


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
Process killing script owix Linux - General 2 07-19-2005 11:08 AM
Problems killing process Artik Debian 6 05-03-2005 10:29 AM
Killing a process by its name rabeea Linux - Networking 3 03-17-2005 05:30 AM
Killing Process probs collen Linux - General 4 09-16-2003 09:18 AM
Really Killing a Process! lazlow69 Linux - Newbie 14 05-10-2003 10:31 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:18 PM.

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