Yii Framework Forum: Installing cron jobs by phpdoc-comment on ConsoleCommand files - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Installing cron jobs by phpdoc-comment on ConsoleCommand files Rate Topic: -----

#1 User is offline   Yiivgeny 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 13-December 11

Posted 17 February 2012 - 06:13 PM

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 =)
1

#2 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 2,601
  • Joined: 10-October 10
  • Location:Denmark

Posted 17 February 2012 - 07:52 PM

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. :)
"Less noise - more signal"
0

#3 User is offline   Yiivgeny 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 13-December 11

Posted 17 February 2012 - 07:57 PM

Thanks =)
0

#4 User is offline   tfotherby 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 12
  • Joined: 11-January 11
  • Location:Reading, UK

Posted 03 June 2012 - 04:23 AM

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!
0

#5 User is offline   bennouna 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,166
  • Joined: 05-January 12
  • Location:Morocco

Posted 03 June 2012 - 05:13 AM

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

#6 User is offline   WalterYip 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 23-May 11

Posted 19 June 2012 - 07:18 AM

could anyone post the detail implementation?
I have lost after installing the extension.
Where should I put my own customization?
0

#7 User is offline   Led 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 201
  • Joined: 16-January 12

Posted 18 December 2012 - 04:10 AM

property "CWebApplication.commandMap" is not defined.

can you help me on this?
0

#8 User is offline   Yiivgeny 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 13-December 11

Posted 18 December 2012 - 05:35 AM

Use console.php config
0

#9 User is offline   Led 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 201
  • Joined: 16-January 12

Posted 18 December 2012 - 08:57 AM

View PostYiivgeny, on 18 December 2012 - 05:35 AM, said:

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)
0

#10 User is offline   Yiivgeny 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 13-December 11

Posted 18 December 2012 - 09:04 AM

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

#11 User is offline   Led 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 201
  • Joined: 16-January 12

Posted 18 December 2012 - 09:08 AM

View PostYiivgeny, on 18 December 2012 - 09:04 AM, said:

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

soory dont understand ,using ubuntu 12.04.
can you help me on this?
0

#12 User is offline   Yiivgeny 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 13-December 11

Posted 18 December 2012 - 09:11 AM

1) Check yiic file permission (0777)
2) Use task:
* * * * * /home/led/documents/casasdeferias/protected/yiic cron > /dev/null
0

#13 User is offline   Led 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 201
  • Joined: 16-January 12

Posted 19 December 2012 - 09:22 AM

View PostYiivgeny, on 18 December 2012 - 09:11 AM, said:

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
0

#14 User is offline   Yiivgeny 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 13-December 11

Posted 19 December 2012 - 09:31 AM

/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"
0

#15 User is offline   Led 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 201
  • Joined: 16-January 12

Posted 27 December 2012 - 06:13 PM

@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'
        ),
    
    ),
);

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users