killproc
Introduction
killproc is a command-line utility to terminate or killl Unix processes by name. The standard Unix kill command identifies processes by process id, rather than by process name. For example, to terminate instances of the django-admin.py script, one might use the following sequence:
$ ps -ef | grep django-admin.py | grep -v grep 501 20060 1 0 0:00.11 ttys001 0:00.38 python django-admin.py runserver 0.0.0.0:8002 501 20063 20060 0 0:00.35 ttys001 0:01.07 python django-admin.py runserver 0.0.0.0:8002 $ kill -TERM 20060 20063 $ ps -ef | grep django-admin.py | grep -v grep
Running the extra ps command and picking out process ids from its output can get rather tedious.
killproc automates this sequence: you provide part of a process name and it executes ps, filtering the results by matching the process name fragment with the CMD column of the ps output. For each match, the user is prompted whether they wish to terminate the process (the prompting can be turned off via a command line option). Accomplishing the above task with killproc might look as follows:
killproc django-admin.py python django-admin.py runserver 0.0.0.0:8002 Kill process 20106? [y] y Sending signal SIGTERM to process 20106 python django-admin.py runserver 0.0.0.0:8002 Kill process 20109? [y] y Sending signal SIGTERM to process 20109 Sent signal SIGTERM to 2 processes
Supported Platforms
killproc has been tested on Mac OSX and Ubuntu Linux. It is expected to work on most Linux and BSD variants.
Installation
killproc is written in Python and packaged using setuptools. It has been registered on PyPi under killproc. Thus, if you have Python and setuptools installed on your machine, you can run install it via easy_install:
easy_install killproc
or pip:
pip killproc
Either command will place the Python package in your Python environment and create the killproc script in your Python’s binary directory (thus making it available in your PATH).
The file killproc.py can function as a standalone command line utility. Thus, as an alternative installation approach, you can grab the killproc.py file out of the source distribution, place it in a directory on your executable path, rename it to killproc, and add execute permissions.
Usage
The command line format for killproc is:
killproc [options] process_name
The available options are:
-h, --help show help message and exit
-k, --with-extreme-prejudice
If specified, use SIGKILL (default is SIGTERM)
-s SIGNAL_NO, --signal=SIGNAL_NO
Use the specified signal. Defaults to 15 (SIGTERM)
-n, --non-interactive
If specified, don't ask user for confirmation
Caveats, Limitations and Future Enhancements
Matching processes are not filtered by user. If the processes of other users match the process name fragment, the killproc user will be prompted for those users as well, and the termination of those processes will fail. As a future enhancement, killproc should return only matching processes of the current user by default, with a command line option to return matches for all users (useful when running as root or sudo).
It would be nice to interpret the process name fragment as a regular expression to be matched against running commands. However, this should not be the default behavior.
Metadata
Release files for killproc 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| killproc-1.0.1.tar.gz | 8.1 kB | Without provenance | Details |
Release files / killproc-1.0.1.tar.gz
| Download URL | killproc-1.0.1.tar.gz |
|---|---|
| Size | 8.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a8a4372248d84d3ea5c36c2a5330fca18f6ed7232790537e6f217199bffd2b58
|
|
BLAKE2b-256 checksum How to use checksums |
4015229627d07d788fd94dfd4070a48647f6ad806dc8f15867fb35f53411872f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for killproc 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.