473,785 Members | 2,412 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Jul 18 '05 #1
3 9908
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?

ta
alex


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

Jul 18 '05 #2
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?


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
Jul 18 '05 #3
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
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.).

Jul 18 '05 #4

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

Similar topics

2
1544
by: Tor Erik Sønvisen | last post by:
Hi. From my Python-program I spawn a new process. When using P_NOWAIT spawnl returns the pid but in windows it returns a process handle. Later I want to kill this process. How can I do this when I only have the process handle? -tores-
7
3001
by: Joe | last post by:
If I'm using process.kill, I can only kill processes, which are created in the same login session. (I'm using win2000, I'm in the local admin group) Processes created by me in earlier logins or even processes of other accounts cannot be killed. I get exceptions, like "You have no permission...". I've tried to do the job in a console application and in a service running under my account (which is in the local admin group of win2000),...
0
2190
by: WATYF | last post by:
This is my problem... I have some code that starts a Process and returns it to a variable... (prcBat) At any time while that process is running... I want to be able to Kill it by pressing a command button in the application. So the code goes something like this: psiBat = New ProcessStartInfo(arrRun.Item(0)(1)) psiBat.WindowStyle = ProcessWindowStyle.Hidden
8
4354
by: MackS | last post by:
Hello! This question does not concern programming in python, but how to manage python processes. Is there a way to "name" a python process? At least on Linux, if I have two python programs running, they both run under the name "python" #pidof program1.py #pidof program1.py
1
10744
by: dusty | last post by:
Hi all, I want to kill a process in Linux (postgres: aaa bbb 192.000.100.00(0000) SELECT waiting). when i try to kill it, it says 'Operation not permitted' Thanks in advance.
3
5923
by: spectrumdt | last post by:
Hello. I am running Fedora Linux and KDE, using the Konsole command line. When coding Python, I regularly make a bug causing my program to not terminate. But how do I kill the non-terminating Python interpreter without killing the entire Konsole? The default way of killing the current process on the command line is Ctrl+C, but that doesn't work with Python. Neither do the "terminate
3
3863
by: Gros Bedo | last post by:
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...
1
2998
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 select the one containing the name of my script ? _________________________________________________________________ Votre contact a choisi Hotmail, l'e-mail nouvelle génération. Créezun compte. http://www.windowslive.fr/hotmail/default.asp
0
2027
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 another wrote: py s.py tokens & capture=$! (get the PID ready)
0
9491
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10357
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10163
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10104
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9959
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7510
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5397
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4063
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.