Skip to content
A PHP component for updating crontab
Branch: master
Clone or download
gavinlove Allow PHP 7.0
We would not recommend using it but since it does not break anything then we should not limit it
Latest commit 6a145bc Oct 19, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
src add timezone option Jan 4, 2018
.gitignore Initial Cronos release commit Oct 23, 2013
LICENSE Update LICENSE Mar 16, 2017


Build Status SensioLabsInsight

Easily configure cron through PHP.

If you use Symfony 2, you could use our cool bundle in order to configure your app jobs through fancy annotations!

Setup and Configuration

Add the following to your composer.json file

    "require": {
        "mybuilder/cronos": "~1.0"

Update the vendor libraries

curl -s | php
php composer.phar install


Build Cron


require 'vendor/autoload.php';

$cron = new MyBuilder\Cronos\Formatter\Cron;
    ->job('/bin/bash command --env=dev')

echo $cron->format();

That will print

1    2    3    4    5    /bin/bash command --env=dev > log 2>> error

Updating Cron


require 'vendor/autoload.php';

use MyBuilder\Cronos\Formatter\Cron;
use MyBuilder\Cronos\Updater\CronUpdater;

$cron = new Cron;
// $cron configuration...

$cronUpdater = CronUpdater::createDefault();


  • The current user must have a existing crontab file to use the updater, use crontab -e to create one.
  • When a cron line is executed it is executed with the user that owns the crontab, but it will not execute any of the users default shell files so all paths etc need to be specified in the command called from the cron line.
  • Your crontab will not be executed if you do not have useable shell in /etc/passwd
  • If your jobs don't seem to be running check that the cron deamon is running, also check your username is in /etc/cron.allow and not in /etc/cron.deny.
  • Environmental substitutions do not work, you can not use things like $PATH, $HOME, or ~/sbin.
  • You can not use % in the command, if you need to use it escape the command in backticks.

Created by MyBuilder - Check out our blog for more insight into this and other open-source projects we release.

You can’t perform that action at this time.