Yiivgeny
(E A Blinov)
February 17, 2012, 11:13pm
1
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 =)
jacmoe
(Jacob Moen)
February 18, 2012, 12:52am
2
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.
tfotherby
(Yiiframework)
June 3, 2012, 9:23am
4
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 !
abennouna
(Abennouna)
June 3, 2012, 10:13am
5
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?
licass
(L R M D)
December 18, 2012, 9:10am
7
property "CWebApplication.commandMap" is not defined.
can you help me on this?
licass
(L R M D)
December 18, 2012, 1:57pm
9
Yiivgeny:
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)
Yiivgeny
(E A Blinov)
December 18, 2012, 2:04pm
10
This problem not relevant for extension. Configure env\cron\output redirecting
licass
(L R M D)
December 18, 2012, 2:08pm
11
soory dont understand ,using ubuntu 12.04.
can you help me on this?
licass
(L R M D)
December 19, 2012, 2:22pm
13
Yiivgeny:
Check yiic file permission (0777)
Use task:
/home/led/documents/casasdeferias/protected/yiic cron > /dev/null
how can i test in command line?
thanks
Yiivgeny
(E A Blinov)
December 19, 2012, 2:31pm
14
/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"
licass
(L R M D)
December 27, 2012, 11:13pm
15
@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'
),
),
);