473,385 Members | 1,402 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Terminate a python script from linux shell / bash script


Hello :-)

I have a question about Python and Linux shell. I have a python program which is permanently resident in the end-user system. I'm currently producing a RPM package, and it works nicely. The problem is that when I uninstall it, my program keeps running in the background, even if the files are deleted.

I know I can terminate python shell directly, but this is not a good ideabecause the end-user may be working with another important python application, and would be very angry if mine would close everything that is usingpython shell.

So, is there a way from the Linux shell or a bash script to terminate just one specific Python script ?
__________________________________________________ _______________
Votre contact a choisi Hotmail, l'e-mail nouvelle génération. Créezun compte.
http://www.windowslive.fr/hotmail/default.asp
Jul 9 '08 #1
3 3838
Gros Bedo wrote:
Hello :-)

I have a question about Python and Linux shell. I have a python program which is permanently resident in the end-user system. I'm currently producing a RPM package, and it works nicely. The problem is that when I uninstall it, my program keeps running in the background, even if the files are deleted.

I know I can terminate python shell directly, but this is not a good idea because the end-user may be working with another important python application, and would be very angry if mine would close everything that is using python shell.

So, is there a way from the Linux shell or a bash script to terminate just one specific Python script ?
__________________________________________________ _______________
Votre contact a choisi Hotmail, l'e-mail nouvelle génération. Créez un compte.
http://www.windowslive.fr/hotmail/default.asp
You should use the signal module to look for SIGINT signal and exit if it is
received.

-Larry
Jul 10 '08 #2
On Jul 10, 1:25*am, Larry Bates <larry.ba...@websafe.com`wrote:
Gros Bedo wrote:
Hello :-)
I have a question about Python and Linux shell. I have a python programwhich is permanently resident in the end-user system. I'm currently producing a RPM package, and it works nicely. The problem is that when I uninstall it, my program keeps running in the background, even if the files are deleted.
I know I can terminate python shell directly, but this is not a good idea because the end-user may be working with another important python application, and would be very angry if mine would close everything that is usingpython shell.
So, is there a way from the Linux shell or a bash script to terminate just one specific Python script ?
__________________________________________________ _______________
Votre contact a choisi Hotmail, l'e-mail nouvelle génération. Créez un compte.
http://www.windowslive.fr/hotmail/default.asp

You should use the signal module to look for SIGINT signal and exit if itis
received.
An alternative, though crude, hack is for the script to check for the
existence (or non-existence) of a special file and quit if found (or
not found). It could also create it when it starts or delete it when
it quits, as appropriate.
Jul 10 '08 #3
>>>>Gros Bedo <gr*******@hotmail.com(GB) wrote:
>GBI have a question about Python and Linux shell. I have a python
GBprogram which is permanently resident in the end-user system. I'm
GBcurrently producing a RPM package, and it works nicely. The problem is
GBthat when I uninstall it, my program keeps running in the background,
GBeven if the files are deleted.
>GBI know I can terminate python shell directly, but this is not a good
GBidea because the end-user may be working with another important python
GBapplication, and would be very angry if mine would close everything
GBthat is using python shell.
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.
--
Piet van Oostrum <pi**@cs.uu.nl>
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: pi**@vanoostrum.org
Jul 10 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Logan | last post by:
Several people asked me for the following HOWTO, so I decided to post it here (though it is still very 'alpha' and might contain many (?) mistakes; didn't test what I wrote, but wrote it - more or...
9
by: TPJ | last post by:
First I have to admit that my English isn't good enough. I'm still studying and sometimes I just can't express what I want to express. A few weeks ago I've written 'Python Builder' - a bash...
8
by: Jan Danielsson | last post by:
Hello all, How do I make a python script actually a _python_ in unix:ish environments? I know about adding: #!/bin/sh ..as the first row in a shell script, but when I installed python on...
16
by: John Salerno | last post by:
Hi all. I just installed Ubuntu and I'm learning how to use the bash shell. Aside from the normal commands you can use, I was wondering if it's possible to use Python from the terminal instead of...
7
by: Frank Potter | last post by:
I learned some python in windows. And now I've turned to linux. I read a book and it teaches how to write shell script with bash, but I don't feel like the grammar of bash. Since I know about...
1
by: Gros Bedo | last post by:
Yes I've seen that each python script calls its own instance of Python. Buthow 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...
0
by: norseman | last post by:
Gros Bedo wrote: ============================== Yes. man ps explains try ps -AFL | grep then kill -9 found (check it more than twice) 1) If your script is known to hang use what...
5
by: aha | last post by:
Hello All, I have a situation where I can count on a Python installation being available on a system, but I can't count on it being a version of Python needed by my application. Since my...
4
by: Stephen Cattaneo | last post by:
Hello all, I am attempting to execute an automated test (written in Python) via cron. I have to check the HOSTNAME variable as part of the test, oddly under cron the HOSTNAME environment...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.