Installing cron jobs by phpdoc-comment on ConsoleCommand files

Installing cron jobs by phpdoc-comment on ConsoleCommand files

Extension sources: github.com/Yiivgeny/Yii-PHPDocCrontab

Example using:


class ExampleRuCommand extends CConsoleCommand{

    /**

     * @cron 10 * * * *

     */

    public function actionExapmle1(){}

}

More examples: github.com/Yiivgeny/Yii-PHPDocCrontab/blob/master/examples/ExampleRuCommand.php

I would publish extension on official extension list. Help me, please =)

Sounds great. :)

You need to help yourself, though, with regards to posting on the extension list.

We want people to be active community members before they can contribute an extension.

Can’t remember, but I think it’s 10 forum posts?

So, interact. :)

Thanks =)

This looks really really really useful. It means developers can manage crons themselves with needing to ask a sysadmin to install crons. The tagging feature is really cool. It means you can tag particular crons to run on particular servers by tweaking the cron arguments a little. For example, if I want to run some crons on our "production" machine, and some on our "primary" production machine I can. Example:

On Test environment machines:


* * * * * /var/www/pph/yiic cron run staging uat

On production machines:


* * * * * /var/www/pph/yiic cron run production

On primary production machine:


* * * * * /var/www/pph/yiic cron run primaryprod

Example of how the Command action is commented with tags:


    /**

     * @cron * * * * *

     * @cron-stdout /tmp/TomsExampleCommand_Staging.log

     * @cron-tags staging

     */

    public function actionEchoStaging()

    {

        echo __METHOD__." was called.\n";


        return true;

    }

Nice. Thanks so much @Yiivgeny!

Hey I missed this thread. Interesting idea. +1 Yiivgeny and thanks.

could anyone post the detail implementation?

I have lost after installing the extension.

Where should I put my own customization?

property "CWebApplication.commandMap" is not defined.

can you help me on this?

Use console.php config

thanks but log

Dec 18 13:56:01 ledled CRON[9337]: (led) CMD (php /home/led/documents/casasdeferias/protected/yiic cron)

Dec 18 13:56:01 ledled CRON[9336]: (CRON) info (No MTA installed, discarding output)

This problem not relevant for extension. Configure env\cron\output redirecting

soory dont understand ,using ubuntu 12.04.

can you help me on this?

  1. Check yiic file permission (0777)

  2. Use task:

          • /home/led/documents/casasdeferias/protected/yiic cron > /dev/null

how can i test in command line?

thanks

/home/led/documents/casasdeferias/protected/yiic cron

/home/led/documents/casasdeferias/protected/yiic cron view

/home/led/documents/casasdeferias/protected/yiic cron run --timestamp="2012-12-12 12:12:12"

@Yiivgeny

dont have output on this commands.

/home/led/documents/casasdeferias/protected/yiic cron

/home/led/documents/casasdeferias/protected/yiic cron view

/home/led/documents/casasdeferias/protected/yiic cron run --timestamp="2012-12-12 12:12:12"

what is wrong


led@ledled:~/Documents/casasdeferias/protected$ /home/led/Documents/casasdeferias/protected/yiic cron run --timestamp="2012-12-12 12:12:12" 

Yii command runner (based on Yii v1.1.12)

Usage: /home/led/Documents/casasdeferias/protected/yiic <command-name> [parameters...]


The following commands are available:

 - message

 - migrate

 - shell

 - test

 - webapp

console.php


return array(

    'basePath' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '..',

    'name' => 'My Console Application',

    'import' => array(

        'application.components.*',

        'application.models.*',

    ),

    // application components

    'components' => array(

        'commandMap' => array(

            'cron' => 'application.extensions.PHPDocCrontab'

        ),

        'db' => array(

            'connectionString' => 'mysql:host=localhost;dbname=casas',

            'username' => 'root',

            'password' => '',

            'charset' => 'utf8',

            'class' => 'CDbConnection'

        ),

    

    ),

);