Skip to content

Cronjobs

xolf edited this page Mar 21, 2017 · 4 revisions

Dreamcoil gives you the option to run your own Cronjob system.

For this you just need to use the Cron class.

$cron = new \Dreamcoil\Cron();

$cron->addJob([
    'command' => 'php ' . __DIR__ . '/eventSystem.php',
    'time' => '* * * * *'
]);

$cron->addJob([
    'command' => 'echo Hello',
    'time' => '* * * * *'
]);

For the time the following structure were used.

*    *    *    *    *    *
-    -    -    -    -    -
|    |    |    |    |    |
|    |    |    |    |    + year [optional]
|    |    |    |    +----- day of week (0 - 7) (Sunday=0 or 7)
|    |    |    +---------- month (1 - 12)
|    |    +--------------- day of month (1 - 31)
|    +-------------------- hour (0 - 23)
+------------------------- min (0 - 59)

Structure

* * * * * Runs every minute

*/5 * * * * Runs every 5 minutes

30 12 */4 * * Runs every 4 day of month on 12:30

addJob(array $job)

You add a job to the Cronjob system. The $job have to contain a command and a time. This should look something like:

$cron->addJob([
    'command' => 'php ' . __DIR__ . '/eventSystem.php',
    'time' => '30 12 * * 5'
]);

run()

This command just runs the Cronjob system.

Navigation

First use

Clone this wiki locally