PHPackages                             chriskonnertz/jobs - 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. [Queues &amp; Workers](/categories/queues)
4. /
5. chriskonnertz/jobs

ActiveLibrary[Queues &amp; Workers](/categories/queues)

chriskonnertz/jobs
==================

Simple cron job manager

v3.2.3(7y ago)62.5kMITPHPPHP &gt;=7.0

Since Nov 21Pushed 7y ago1 watchersCompare

[ Source](https://github.com/chriskonnertz/Jobs)[ Packagist](https://packagist.org/packages/chriskonnertz/jobs)[ RSS](/packages/chriskonnertz-jobs/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)DependenciesVersions (10)Used By (0)

Jobs
====

[](#jobs)

Minimalistic Cron job manager. Register jobs and the job manager will execute them automatically depending on their interval.

> NOTE: This is not a queue manager and therefore this has nothing to do with Laravel's queue component. Also note that Laravel 5 has an integrated [task scheduler](https://laravel.com/docs/5.7/scheduling) that works similar to this library.

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

[](#installation)

> This library requires PHP &gt;= 7.0

Add `chriskonnertz/jobs` to `composer.json`:

```
"chriskonnertz/jobs": "3.*"

```

Or via a console:

```
composer require chriskonnertz/jobs

```

In the future run `composer update` to update to the latest version of this library.

### Framework support

[](#framework-support)

This library supports Laravel &gt;=5.5 with a service provider. Add the service provider to the config file `config/app.php`:

```
    'providers' => array(
        // ...
        'ChrisKonnertz\Jobs\Integration\JobsServiceProvider',
    ),
```

To create an alias for the facade, add this new entry in this file:

```
    'aliases' => array(
        // ...
        'Jobs' => 'ChrisKonnertz\Jobs\Integration\JobsFacade',
        'AbstractJob' => 'ChrisKonnertz\Jobs\AbstractJob',
    ),
```

Introduction
------------

[](#introduction)

Create a concrete job class:

```
    class ExampleJob extends ChrisKonnertz\Jobs\AbstractJob
    {

        protected $name = 'exampleJob';

        protected $interval = 5; // Run every five minutes

        public function run(int $executedAt = null)
        {
            echo 'Hello World!';
        }

    }
```

Instantiate the job manager:

```
    $cache = new ExampleCacheClass;
    $jobs = new ChrisKonnertz\Jobs\Jobs($cache);
```

> If you use Laravel with the service provider you do not have to worry about this. The service provider will inject the cache dependency. In any other case the cache class has to implement the cache interface (`CacheInterface`). Take a look at the `LaravelCache` class (that is meant for Laravel integration) for an example implementation.

Register the job:

```
    $jobs->addLazy('updateStreams', 'ExampleJob');
```

Execute the registered jobs:

```
    $jobs->run();
```

### Automatically execute jobs

[](#automatically-execute-jobs)

If your application is built on top of Laravel, you will have access to an Artisan command: `php artisan jobs` This command will call `Jobs::run()` to execute the jobs. Therefore you can add a Cron job to the crontab to start the command, for example `1 * * * * php /var/www/laravel/artisan jobs`. This will execute the Artisan command every minute. We recommend to run the Cron job every minute.

Methods of the jobs manager
---------------------------

[](#methods-of-the-jobs-manager)

> Note: Some of these methods may throw a `JobException`.

### Determine if a job exists in the pool

[](#determine-if-a-job-exists-in-the-pool)

```
    $hasJob = $jobs->has('exampleJob');
```

### Add a job to the pool (without lazy loading)

[](#add-a-job-to-the-pool-without-lazy-loading)

```
    $job = new ExampleJob;
    $jobs->add($job);
```

### Add a job to the pool (with lazy loading)

[](#add-a-job-to-the-pool-with-lazy-loading)

```
    // Pass the class name:
    $jobs->addLazy(\My\Example\Job::class);

    // Or pass a closure:
    $jobs->addLazy(function()
    {
        return new ExampleJob;
    });
```

We recommend using `addLazy()` over `add()`.

### Remove a job from the pool

[](#remove-a-job-from-the-pool)

```
    $jobs->remove('exampleJob');
```

### Remove all jobs from the pool

[](#remove-all-jobs-from-the-pool)

```
    $jobs->clear();
```

### Count the jobs

[](#count-the-jobs)

```
    $howMany = $jobs->count();
```

### Get the remaining cool down

[](#get-the-remaining-cool-down)

```
$minutes = $jobs->remainingCoolDown();
```

### Get the timestamp of the last iteration

[](#get-the-timestamp-of-the-last-iteration)

```
$timestamp =  $jobs->lastRunAt();
```

### Set the minimum cool down time for all jobs

[](#set-the-minimum-cool-down-time-for-all-jobs)

```
    $jobs->coolDown(1); // One minute
```

The minimum value and the initial value is one minute. Most likely there is no reason to change this value ever.

### Set the cache key namespace

[](#set-the-cache-key-namespace)

```
    $jobs->cacheKey('jobs.');
```

The job class
-------------

[](#the-job-class)

A job class implements the job interface. Therefore it has to implement these methods:

```
    interface JobInterface
    {

        public function getName() : string; // The name (identifier) of the job

        public function getActive() : bool; // Active or paused (=not executed)?

        public function getInterval() : int; // The cool down time

        public function run(int $executedAt = null); // The run method

    }
```

The `AbstractJob` class actually implements these methods so we recommend to let your concrete job classes inherit from this class. The abstract class provides the attributes `name`, `active` and `interval` that inheriting classes may overwrite.

### The interval

[](#the-interval)

Per default (as long as the inheriting job class does not overwrite it) the `getInterval()` is a simple getter for the `interval` attribute. The `interval` attribute defines the duration of the job's cool down in minutes. For example if it is `60` minutes (= `1` hour) the job is executed once per hour (max).

Status
------

[](#status)

Status of this repository: **Deprecated**. Issues will be fixed but no new feature implemented.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community7

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

Recently: every ~25 days

Total

9

Last Release

2582d ago

Major Versions

v1.0 → v2.0-beta2016-09-17

v2.0 → v3.02018-03-17

PHP version history (2 changes)v1.0PHP &gt;=5.3.7

v3.2.2PHP &gt;=7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/2548d359f2033681fd886f21a31406119a9ea3bd93dbec6f533f75f006f09228?d=identicon)[siconize](/maintainers/siconize)

---

Top Contributors

[![chriskonnertz](https://avatars.githubusercontent.com/u/4319323?v=4)](https://github.com/chriskonnertz "chriskonnertz (123 commits)")

---

Tags

automatecronjobjobslaravelmanagephpscheduleschedulinglaraveljobcron jobcron jobs

### Embed Badge

![Health badge](/badges/chriskonnertz-jobs/health.svg)

```
[![Health](https://phpackages.com/badges/chriskonnertz-jobs/health.svg)](https://phpackages.com/packages/chriskonnertz-jobs)
```

###  Alternatives

[lorisleiva/laravel-actions

Laravel components that take care of one specific task

2.8k7.5M115](/packages/lorisleiva-laravel-actions)[mpbarlow/laravel-queue-debouncer

A wrapper job for debouncing other queue jobs.

63714.4k1](/packages/mpbarlow-laravel-queue-debouncer)[pmatseykanets/artisan-beans

Easily manage your Beanstalkd job queues right from the Laravel artisan command

4482.1k](/packages/pmatseykanets-artisan-beans)[renoki-co/horizon-exporter

Export Laravel Horizon metrics using this Prometheus exporter.

24152.7k](/packages/renoki-co-horizon-exporter)[maqe/laravel-sqs-fifo

Laravel package that enables support for SQS FIFO Queue

15137.2k](/packages/maqe-laravel-sqs-fifo)[tochka-developers/queue-promises

Promises for Laravel queue jobs

1912.3k](/packages/tochka-developers-queue-promises)

PHPackages © 2026

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