nicest way to kill python process running on linux?

A

Alex Hunsley

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
 
N

Neal D. Becker

Alex said:
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

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

Helmut Jarausch

Alex said:
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?

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
 
C

Christopher T King

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.).
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,202
Messages
2,571,057
Members
47,661
Latest member
sxarexu

Latest Threads

Top