Yii 1.1: phpdoc-crontab

Simple and convenient installing console commands as cron jobs.


Simple and convenient installing console commands as cron jobs.

  • One control point to run all commands
  • Crossplatform job installing
  • Store schedule of launches with application source
  • Grouping jobs (example: segmentation by server)


Installing action 'Example1' of command 'Test' to run every 10 minutes. Just add doc-comment for console action.

class TestCommand extends CConsoleCommand{
     * @cron 10 * * * *
    public function actionExample1(){}


  • Step 1: Put directory PHPDocCrontab (or only PHPDocCrontab.php) into your framework extensions directory.
  • Step 2: Add PHPDocCrontab.php as new console command on framework config:
'commandMap' => array(
    'cron' => 'ext.PHPDocCrontab.PHPDocCrontab'
  • Step 3: Add task to system scheduler (cron on unix, task scheduler on windows) to run every minute:
* * * * * /path/to/yii/application/protected/yiic cron


Yii Framework 1.1.6 or above


  • 2012-11-09: Adding logFileName option with support date & task placeholders


Total 5 comments

#18433 report it
Delphine at 2014/10/28 12:04pm
Execute one method

I would like to know how to execute only one method in ExampleRuCommand.php ?

For Example, I would like to execute actionExample1 every minute and actionexample2 every hour..

#12724 report it
Yiivgeny at 2013/04/08 07:59am
Add comment and task to scheduler

You should add doc-comment @cron * * * 1 * to CConsoleCommand action and add task /path/to/app/protected/yiic.bat cron run on every minute

#12723 report it
ddsultan at 2013/04/08 07:49am
What Should I do in order to run it automatically every month?

Hello! Could you help me? What Should I do in order to run it automatically every month: **whether ** I should specify the file (PHP Class or ?) in Windows Scheduler. Thanks in advance!

#8436 report it
Yiivgeny at 2012/06/03 07:21am
phpdoc-crontab crons run in parallel

You are definitely right, they are really parallel.

#8434 report it
tfotherby at 2012/06/03 06:28am
Do phpdoc-crontab crons run in parallel or in serial?

On a GNU/Linux system, if I have setup many crons to run for example at 10am, they would be triggered at the same time and executed in parallel. If I moved them over to this extension, would this still be the case or would they run in serial? I have seen the runCommandBackground() function in the code so I think they would run in parallel but I wanted to ask to be 100% sure...

Cheers, Tom

Leave a comment

Please to leave your comment.

Create extension