PHPackages                             narekps/php-cron - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. narekps/php-cron

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

narekps/php-cron
================

Cronjobs

1.6(4y ago)011.8kMITPHPPHP ^7.2 || ^8.0

Since Mar 4Pushed 4y agoCompare

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

READMEChangelogDependencies (2)Versions (26)Used By (0)

Cron
====

[](#cron)

[![Packagist](https://camo.githubusercontent.com/e813e02afd3b5b16d85f6588fbab22359a60be16dddf8ca067db497cc412cc65/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f63726f6e2f63726f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/cron/cron)[![Build Status](https://camo.githubusercontent.com/ba2489d727d3035fc880c846ecdf3543f1fc81290601b902f72c02af50dbdfc7/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f43726f6e2f43726f6e2e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/Cron/Cron)[![Quality](https://camo.githubusercontent.com/2d6198aa786e0ca20b397341c8ee134c64171011fba7cc338ddd92c0d46a3c96/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f43726f6e2f43726f6e2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/Cron/Cron)[![Coverage](https://camo.githubusercontent.com/60f39942bd79d0e14bc410c178953c3b7d1aa61472704695121ca13095b06970/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f43726f6e2f43726f6e2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/Cron/Cron)[![SensioLabs Insight](https://camo.githubusercontent.com/89d178d0615c6d8b4ddc17d1a3a74e7d520e7e7c1c9428b3ef8d77a55585ac71/68747470733a2f2f696d672e736869656c64732e696f2f73656e73696f6c6162732f692f66343939326264372d383936612d343334302d623262352d6433616635623238313130312e7376673f7374796c653d666c61742d737175617265)](https://insight.sensiolabs.com/projects/f4992bd7-896a-4340-b2b5-d3af5b281101)[![Packagist](https://camo.githubusercontent.com/95cc67d8994060752d1a476c124f00443a721bea84d10ed156b220e998a30da6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f43726f6e2f43726f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/cron/cron)[![License](https://camo.githubusercontent.com/942e017bf0672002dd32a857c95d66f28c5900ab541838c6c664442516309c8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)](LICENSE)

This library enables you to have only one general crontab entry that will trigger several different cronjobs that can be defined through this library. The Cron library will decide if the job needs to run or not.

**Attention**: make sure you set the server crontab job to a correctly chosen frequency because if there is for example a cronjob defined in code to run every minute, your general crontab job needs to run at least every minute as well to work properly.

Use Case
--------

[](#use-case)

Say you need two cronjobs in your application. One that will write the contents of a folder to a log file, and one that will empty the folder. This library enables you to create separate scripts (for example: cron.php) where you notify the Cron library of the two cronjobs. After defining the Jobs with their specifics, they can be added to the resolver and the run command can be given.

Your server crontab could now look something like:

```
* * * * * /path/to/php /path/to/cron.php >/dev/null 2>&1

```

The code example below is matched to this use case.

Code example
------------

[](#code-example)

```
