nicest way to kill python process running on linux?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alex Hunsley

    nicest way to kill python process running on linux?

    I'm running a monitoring script under linux written in python. It's nohup'ed so
    that I can log out and it will continue running happily and so on, but
    sometimes I need to kill the script before editing the source and relaunching it.
    Question is, what's the nicest way to kill the python process under linux? Is a
    simple 'kill [process-id]' the nicest way to do it, or is there a different
    signal I should send it?

    ta
    alex

  • Neal D. Becker

    #2
    Re: nicest way to kill python process running on linux?

    Alex Hunsley wrote:
    [color=blue]
    > I'm running a monitoring script under linux written in python. It's
    > nohup'ed so that I can log out and it will continue running happily and so
    > on, but sometimes I need to kill the script before editing the source and
    > relaunching it. Question is, what's the nicest way to kill the python
    > process under linux? Is a simple 'kill [process-id]' the nicest way to do
    > it, or is there a different signal I should send it?
    >
    > ta
    > alex
    >[/color]

    nice +10 kill [process-id]
    (sorry, couldn't resist)

    Comment

    • Helmut Jarausch

      #3
      Re: nicest way to kill python process running on linux?

      Alex Hunsley wrote:[color=blue]
      > I'm running a monitoring script under linux written in python. It's
      > nohup'ed so that I can log out and it will continue running happily and
      > so on, but sometimes I need to kill the script before editing the source
      > and relaunching it.
      > Question is, what's the nicest way to kill the python process under
      > linux? Is a simple 'kill [process-id]' the nicest way to do it, or is
      > there a different signal I should send it?
      >[/color]

      It's a matter of convention, e.g. xinetd uses the USR2 signal.
      Unless you use kill -9 which can't be handled by the application
      anything is fine if the user knows what signal to send and your script
      catches the signal to stop gracefully.


      --
      Helmut Jarausch

      Lehrstuhl fuer Numerische Mathematik
      RWTH - Aachen University
      D 52056 Aachen, Germany

      Comment

      • Christopher T King

        #4
        Re: nicest way to kill python process running on linux?

        On Mon, 12 Jul 2004, Alex Hunsley wrote:
        [color=blue]
        > I'm running a monitoring script under linux written in python. It's
        > nohup'ed so that I can log out and it will continue running happily and
        > so on, but sometimes I need to kill the script before editing the source
        > and relaunching it. Question is, what's the nicest way to kill the
        > python process under linux? Is a simple 'kill [process-id]' the nicest
        > way to do it, or is there a different signal I should send it?[/color]

        If you want to be really nice, kill -SIGINT [pid] will generate a
        KeyboardInterru pt in Python that can be caught by the Python program, but
        the program could be set to ignore it. Otherwise kill [pid] (equivalent
        to kill -SIGTERM [pid]) is nice enough (it allows Python to do cleanup,
        etc.).

        Comment

        Working...