nicest way to kill python process running on linux?
Christopher T King
squirrel at WPI.EDU
Mon Jul 12 09:52:42 EDT 2004
On Mon, 12 Jul 2004, Alex Hunsley wrote:
> 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?
If you want to be really nice, kill -SIGINT [pid] will generate a
KeyboardInterrupt 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.).
More information about the Python-list
mailing list