PHPackages                             ofbeaton/command-running - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. ofbeaton/command-running

ActiveLibrary[CLI &amp; Console](/categories/cli)

ofbeaton/command-running
========================

Detects if a command or process is currently running.

1.0.0(10y ago)3207MITPHPPHP &gt;=5.4

Since Aug 7Pushed 7y ago3 watchersCompare

[ Source](https://github.com/ofbeaton/command-running)[ Packagist](https://packagist.org/packages/ofbeaton/command-running)[ Docs](https://github.com/ofbeaton/command-running)[ RSS](/packages/ofbeaton-command-running/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (7)Versions (10)Used By (0)

command-running
===============

[](#command-running)

Detects if a command or process is currently running and optionally kill it.

[![Latest Stable Version](https://camo.githubusercontent.com/67a740d21d13ab1d241606094aed36163e86838075faaf3516ad924a23cbe360/68747470733a2f2f706f7365722e707567782e6f72672f6f66626561746f6e2f636f6d6d616e642d72756e6e696e672f762f737461626c652e706e67)](https://packagist.org/packages/ofbeaton/command-running)[![Build Status](https://camo.githubusercontent.com/937980c9b8bb1c6fcfc63adce1012eb3c76988ef399a16f5db46b5532152cf78/68747470733a2f2f7472617669732d63692e6f72672f6f66626561746f6e2f636f6d6d616e642d72756e6e696e672e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/ofbeaton/command-running)[![Dependency Status](https://camo.githubusercontent.com/5b59eeab08a1a420d7d30872cb2d46742a8a319a944d236857c4ef9412900819/68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f7068702f6f66626561746f6e3a636f6d6d616e642d72756e6e696e672f62616467652e7376673f7374796c653d666c6174)](https://www.versioneye.com/php/ofbeaton:command-running)[![Total Downloads](https://camo.githubusercontent.com/54f359f03142b8824e04f32f2d02ca4322e047711c6de93c76973ee728674b00/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f66626561746f6e2f636f6d6d616e642d72756e6e696e672e737667)](https://packagist.org/packages/ofbeaton/command-running)[![License](https://camo.githubusercontent.com/5f1738ee2bbb36e8c3ab54f18e06fcd9565823527d3de5a8237234f624234e2a/68747470733a2f2f706f7365722e707567782e6f72672f6f66626561746f6e2f636f6d6d616e642d72756e6e696e672f6c6963656e7365)](LICENSE)

Currently supports:

- Linux
- Windows

Please note that `getPids()` on windows is slow (2 seconds). There may be a way to speed it up using `WMI` in the future.

Alternatives
------------

[](#alternatives)

If you don't need advanced features, you can use the [Symfony Lock component and trait](https://symfony.com/doc/master/console/lockable_trait.html) in any application, even non-symfony ones. It is actively maintained and is likely more up to date.

It supports filesystem (FlockStore), shared memory (SemaphoreStore) and even databases and Redis servers.

It does not support force claims, kills, or reports.

Updates
-------

[](#updates)

The project is considered in a usable state and feature complete.

This project is used in corporate applications. As such, the authors are unlikely to update it on a regular basis, but instead when the corporate applications that use it run into problems. You should expect updates in the 5-10yr range.

Issues and PRs will be monitored, and we will continue to work with the community to provide updates as they are contributed.

Installing via Composer
-----------------------

[](#installing-via-composer)

The recommended way to install Command Running is through [Composer](http://getcomposer.org).

```
# Install Composer
curl -sS https://getcomposer.org/installer | php
```

Next, run the Composer command to install the latest stable version:

```
composer.phar require ofbeaton/command-running
```

After installing, you can now use it in your code:

```
    $pidfile = 'mypidfile.txt';
    $running = new \Ofbeaton\Command\Running($pidfile);

    $ok = $running->claimPidFile();
    if ($ok === false) {
        echo 'We are currently already running'.PHP_EOL;
        exit;
    }

    // your code

    // at the end of your program
    $running->releasePidFile();
```

For more detailed usage, see the [Forever Example](examples/forever).

License
-------

[](#license)

This software is distributed under the MIT License. Please see [License file](LICENSE) for more information.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

9

Last Release

3924d ago

Major Versions

0.4.0 → 1.0.02015-08-20

### Community

Maintainers

![](https://www.gravatar.com/avatar/bc1f698134d2f7261eeeb6b8d9d5c118fd8315496f7e4444b6d16b281e3d1287?d=identicon)[ofbeaton](/maintainers/ofbeaton)

---

Top Contributors

[![ofbeaton](https://avatars.githubusercontent.com/u/1781089?v=4)](https://github.com/ofbeaton "ofbeaton (40 commits)")

---

Tags

command-linelockphprunningconsolecommandpidkill

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/ofbeaton-command-running/health.svg)

```
[![Health](https://phpackages.com/badges/ofbeaton-command-running/health.svg)](https://phpackages.com/packages/ofbeaton-command-running)
```

###  Alternatives

[helhum/typo3-console

A reliable and powerful command line interface for TYPO3 CMS

2939.0M192](/packages/helhum-typo3-console)[adhocore/cli

Command line interface library for PHP

3501.2M50](/packages/adhocore-cli)[aplus/cli

Aplus Framework CLI Library

2301.7M6](/packages/aplus-cli)[illuminated/console-mutex

Mutex for Laravel Console Commands.

146938.2k1](/packages/illuminated-console-mutex)[laminas/laminas-cli

Command-line interface for Laminas projects

563.7M54](/packages/laminas-laminas-cli)[zenstruck/console-extra

A modular set of features to reduce configuration boilerplate for your Symfony commands.

8057.6k1](/packages/zenstruck-console-extra)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
