LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-04-2005, 03:01 AM   #1
melinda_sayang
Member
 
Registered: Dec 2003
Location: Petaling Jaya
Distribution: Ubuntu
Posts: 475

Rep: Reputation: 31
how to kill specific python script


Hi,

I have two running python script, that launched by:
$ python blabla.py
$ python bubu.py

How do I kill specific python script from another script? I want to kill "python blabla.py" process, but don't want to kill "python bubu.py" process.

$ killall python

kill all python programs

$ killall blabla.py

cannot find blabla.py process

You may say that try to kill <PID>, but how do I know pid of "python blabla.py" process from the another script? Launch "ps aux" from the script then get the pid from there is an ugly way, I think.

Any idea?
 
Old 12-04-2005, 03:21 AM   #2
Artanicus
Member
 
Registered: Jan 2005
Location: Finland
Distribution: Ubuntu, Debian, Gentoo, Slackware
Posts: 827

Rep: Reputation: 31
pkill and pgrep might be useful to you.. So:

Code:
pgrep -f blabla.py # will give you its pid

pkill -9 -f blabla.py # kills the matching pid

Last edited by Artanicus; 12-04-2005 at 03:23 AM.
 
Old 12-04-2005, 03:31 AM   #3
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 97
Hi.
Code:
kill $(ps aux | grep python blabla.py | awk '{ print $2 }')
is what I'd do from a shell script. It might be useful for your python script too.

Dave
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Kill specific Wine program from Command Line Brian114 Linux - Software 4 06-07-2011 04:02 AM
why my script die itself when I try to kill a process?? jaimese Linux - Newbie 4 10-27-2005 05:50 AM
python cgi script and premature end of script headers Neruocomp Programming 1 07-28-2005 11:43 AM
kill a specific session in windows rabeea General 8 12-15-2004 03:10 PM
php script to kill the popups from no-ip.com _MD_ Linux - General 1 04-15-2004 10:52 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:09 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