Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install killproc

How to install killproc

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install killproc
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
1.0.1 Available View build log
1.0.0 Available View build log
Windows (64-bit)
1.0.1 Available View build log
1.0.0 Available View build log
Mac OS X (10.5+)
1.0.1 Available View build log
1.0.0 Available View build log
Linux (32-bit)
1.0.1 Available View build log
1.0.0 Available View build log
Linux (64-bit)
1.0.1 Available View build log
1.0.0 Available View build log
 
Author
License
Apache V2.0
Imports
Lastest release
version 1.0.1 on Apr 29th, 2011

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

System Message: ERROR/3 (<string>, line 11)

Inconsistent literal block quoting.

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:

System Message: WARNING/2 (<string>, line 24)

Literal block expected; none found.

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:

System Message: WARNING/2 (<string>, line 45)

Literal block expected; none found.

easy_install killproc

or pip:

System Message: WARNING/2 (<string>, line 49)

Literal block expected; none found.

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:

System Message: WARNING/2 (<string>, line 63)

Literal block expected; none found.

killproc [options] process_name

The available options are:

-h, --help            show help message and exit
-k, --with-extreme-prejudice

System Message: ERROR/3 (<string>, line 69)

Inconsistent literal block quoting.

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.

Subscribe to package updates

Last updated Apr 29th, 2011

Download Stats

Last month:2

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.