PHPackages                             mluex/endless-cron-command - 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. mluex/endless-cron-command

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

mluex/endless-cron-command
==========================

Extension of wrep/daemonizable-command to easily run endless Symfony commands as cronjobs.

5.0.2(1y ago)054MITPHP

Since Oct 13Pushed 1y ago1 watchersCompare

[ Source](https://github.com/mluex/endless-cron-command)[ Packagist](https://packagist.org/packages/mluex/endless-cron-command)[ Docs](https://github.com/mluex/endless-cron-command)[ RSS](/packages/mluex-endless-cron-command/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (6)Dependencies (3)Versions (9)Used By (0)

Endless Cron Commands for Symfony
=================================

[](#endless-cron-commands-for-symfony)

This package is a small extension of [wrep/daemonizable-command](https://packagist.org/packages/wrep/daemonizable-command). If no Upstart or systemd are available to set up a daemon, a simple cronjob and Symfony Lock are sufficient to produce an almost similar result.

Detailed information on Daemonizable / Endless Commands
-------------------------------------------------------

[](#detailed-information-on-daemonizable--endless-commands)

Check out the documentation of wrep/daemonizable-command for more information on how to create endless commands: [wrep/daemonizable-command](https://packagist.org/packages/wrep/daemonizable-command)

Installation
------------

[](#installation)

`composer require mluex/endless-cron-command`

### Which version to use?

[](#which-version-to-use)

- Version 5.\* for Symfony 7 and higher
- Version 4.\* for Symfony 6

Usage
-----

[](#usage)

### 1. Configuration

[](#1-configuration)

EndlessCronCommands require symfony/lock to ensure that only one instance is executed at a time. Please configure the bundle accordingly in your .env.local, e.g.

```
###> symfony/lock ###
LOCK_STORE_DSN=mysql:host=127.0.0.1;dbname=app
###< symfony/lock ###
```

⚠️ Make sure to use a lock store that supports expiry! Check the [Symfony Lock documentation](https://symfony.com/doc/current/components/lock.html) for more information.

### 2. Implementation

[](#2-implementation)

Create a Symfony command that extends `EndlessCronCommand` and off you go. Here is a minimal example:

```
namespace Acme\DemoBundle\Command;

use Mluex\EndlessCronCommand\EndlessCronCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class MinimalDemoCommand extends EndlessCronCommand
{
    // This is just a normal Command::configure() method
    protected function configure(): void
    {
        $this->setName('acme:minimaldemo')
            ->setDescription('An EndlessCronCommand implementation example');
    }

    // Method will be called in an endless loop
    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        // Do some work
        file_put_contents('/tmp/acme-timestamp.txt', time());
    }
}
```

If your command includes Monolog's FingersCrossed Log Handlers, you may want to clear them after every iteration as wrep pointed out in his [documentation](https://github.com/mac-cain13/daemonizable-command?tab=readme-ov-file#memory-usage-and-leaks). EndlessCronCommand provides a method for this:

```
namespace Acme\DemoBundle\Command;

use Mluex\EndlessCronCommand\EndlessCronCommand;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class MinimalDemoCommand extends EndlessCronCommand
{
    public function __construct(
        private readonly LoggerInterface $logger,
        string $name = null
    ) {
        parent::__construct($name);
    }

    // This is just a normal Command::configure() method
    protected function configure(): void
    {
        $this->setName('acme:minimaldemo')
            ->setDescription('An EndlessCronCommand implementation example');
    }

    // Method will be called in an endless loop
    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        // Do some work
        file_put_contents('/tmp/acme-timestamp.txt', time());

        // Clear FingersCrossed Log Handlers
        $this->clearFingersCrossedLogHandlers($this->logger);
    }
}
```

### 3. Cronjob setup

[](#3-cronjob-setup)

Add a cronjob to your crontab to run the command every minute.

```
* * * * * php /path/to/your/project/bin/console acme:minimaldemo >/dev/null 2>&1
```

### 4. Advanced usage

[](#4-advanced-usage)

It may make sense to limit the runtime of an instance and restart the command regularly. Use the runtime option for this:

```
* * * * * php /path/to/your/project/bin/console acme:minimaldemo --runtime=600 >/dev/null 2>&1
```

In order to run the command's execute() method more often in the main loop (default is 5 sec), you can use the frequency option to set a lower timeout between iterations (1 sec in this example):

```
* * * * * php /path/to/your/project/bin/console acme:minimaldemo --frequency=1 >/dev/null 2>&1
```

Every iteration will refresh the lock and push its expiry time further into the future. If the command crashes, the lock will expire after the lock-ttl time and the next cronjob will start a new instance. You can set the lock-ttl to a lower value to ensure that the command is restarted more quickly after a crash:

```
* * * * * php /path/to/your/project/bin/console acme:minimaldemo --lock-ttl=60 >/dev/null 2>&1
```

TODO
----

[](#todo)

- Examples
- Unit Tests

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance37

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 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 ~0 days

Total

8

Last Release

573d ago

Major Versions

4.1.1 → 5.0.02024-10-13

4.1.2 → 5.0.12024-10-14

4.x-dev → 5.0.22024-10-14

### Community

Maintainers

![](https://www.gravatar.com/avatar/038e95175fdc7e8a07120c32db14e2ac75ab46a476fef9014cc19240c4d42a02?d=identicon)[mluex](/maintainers/mluex)

---

Top Contributors

[![mluex](https://avatars.githubusercontent.com/u/20678805?v=4)](https://github.com/mluex "mluex (9 commits)")

---

Tags

symfonycrondaemonbackground processlong running process

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mluex-endless-cron-command/health.svg)

```
[![Health](https://phpackages.com/badges/mluex-endless-cron-command/health.svg)](https://phpackages.com/packages/mluex-endless-cron-command)
```

###  Alternatives

[wrep/daemonizable-command

Daemonizable (endless running) commands for Symfony.

2271.5M6](/packages/wrep-daemonizable-command)[jmose/command-scheduler-bundle

This Symfony bundle will allow you to schedule all your commands just like UNIX crontab

3361.4M1](/packages/jmose-command-scheduler-bundle)[crunzphp/crunz

Schedule your tasks right from the code.

2292.0M6](/packages/crunzphp-crunz)[shapecode/cron-bundle

This bundle provides scheduled execution of Symfony commands

59493.0k2](/packages/shapecode-cron-bundle)[phlib/console-process

Console implementation.

1833.5k2](/packages/phlib-console-process)[duncan3dc/console

Create command line php applications using symfony/console

17263.4k1](/packages/duncan3dc-console)

PHPackages © 2026

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