Crontab is library for CodeIgniter framework for handling cronjobs of project


This library is very simple, but it's designed to be so.

What does it do

This library sets up cron to perform tasks from crontab file.
When crontab file is written with this library. Almost all you
need is set up config/crontab.php file.


   1. Download library from github repository git://
   2. If you are familiar with phpunit you can test library. Tests are located in tests subdirectory
   3. Copy config/crontab.php and libraries/crontab.php
   4. Setup config/crontab.php
   5. Use this library

Crontab library config file

    Path to cronfile library will write all jobs
    Path to PHP executable
    Crontab library default format for date() function
    PHP cli scripts path
    This config variable can be used when your server has different timezone
    from timezone of tasks you want to be cheduled. e.g. server is in -5 timezone.
    backend in +1 timezone. in backend you setting cronjob for 00:00:00,
    but for server this would be 14:00:00

Library usage examples

Simple usage

To execute cli script every day at midnight n your controller you should put following code:

$this->crontab->add_job('0 0 * * *', 'cli_script.php');

This code will execute cli_script.php located in directory you've set
up in config file at 0 minutes 0 hour

Advanced usage
Assuming you have in your $_POST['time'] time when scheduled action should be performed.

$time = $this->crontab->translate_timestamp(strtotime($this->input->post('time')), 's i G * *');
$this->crontab->add_job($time, 'cli_script.php');

If you want to perform an action every day after user submit a data:

$time = $this->crontab->translate_timestamp(time(), 's i G * *');
$this->crontab->add_job($time, 'cli_script.php');