Terminate a python script from linux shell / bash script

Discussion in 'Python' started by Gros Bedo, Jul 9, 2008.

  1. Gros Bedo

    Gros Bedo Guest

    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
     
    Gros Bedo, Jul 9, 2008
    #1
    1. Advertising

  2. Gros Bedo

    MRAB Guest

    On Jul 10, 1:25 am, Larry Bates <`> wrote:
    > 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.
    >

    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.
     
    MRAB, Jul 10, 2008
    #2
    1. Advertising

  3. >>>>> Gros Bedo <> (GB) wrote:

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


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

    >GB> So, is there a way from the Linux shell or a bash script to terminate
    >GB> just one specific Python script ?


    So just kill it.
    --
    Piet van Oostrum <>
    URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
    Private email:
     
    Piet van Oostrum, Jul 10, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. William Park

    (patch for Bash) GTK+2 + Bash

    William Park, Jul 11, 2005, in forum: XML
    Replies:
    3
    Views:
    2,331
    William Park
    Jul 14, 2005
  2. Gros Bedo
    Replies:
    1
    Views:
    691
    Piet van Oostrum
    Jul 10, 2008
  3. norseman
    Replies:
    0
    Views:
    588
    norseman
    Jul 10, 2008
  4. Gros Bedo
    Replies:
    0
    Views:
    446
    Gros Bedo
    Jul 13, 2008
  5. edwithad

    Bash shell to Python shell?

    edwithad, Sep 28, 2009, in forum: Python
    Replies:
    4
    Views:
    1,810
Loading...

Share This Page