471,873 Members | 1,824 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,873 software developers and data experts.

Re: Terminate a python script from linux shell / bash script


Gros Bedo wrote:
>
>>That's not how it works. If you kill one running python script it will not
effect other python scripts. Each script has its own interpreter process
running.
>GBSo, is there a way from the Linux shell or a bash script to terminate
GBjust one specific Python script ?
>>So just kill it.

Yes I've seen that each python script calls its own instance of Python. But how to know which is the good one in bash ? Is there a command that gets the parameters of process, so I could use grep to select the one containing the name of my script ?
__________________________________________________ _______________
Votre contact a choisi Hotmail, l'e-mail nouvelle génération. Créez un compte.
http://www.windowslive.fr/hotmail/default.asp
--
http://mail.python.org/mailman/listinfo/python-list
==============================
Yes. man ps explains
try ps -AFL | grep [known filename or cmdlin token]
then kill -9 [PID] found (check it more than twice)

1) If your script is known to hang use what another wrote:
py s.py tokens &
capture=$! (get the PID ready)
kill -9 $capture

2) If you are like the other 99% needing the PID because we didn't know
we were going to need it, use the ps/grep combo.
Try not to damage your system.
Which means: Trying to automate this is VERY dangerous!
How long since your last full backup? And of course you
can redo everything since last backup from memory, yes?
It hangs, you kill it manually.

Steve
no******@hughes.net

Jul 10 '08 #1
0 1805

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Logan | last post: by
8 posts views Thread by Jan Danielsson | last post: by
7 posts views Thread by Frank Potter | last post: by
5 posts views Thread by aha | last post: by
4 posts views Thread by Stephen Cattaneo | last post: by
reply views Thread by zermasroor | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.