sfMCronPlugin
1.1.1stable
for sf 1.4sf 1.3sf 1.2 MIT
The sfCron is a symfony plugin that provides a convenient work with cron.
This plugin allows to execute function & class methods according certain time specification.
With this plugin you can add, delete handlers, watch their list. Display priorities launch, monitor the work of handlers.
Developers
| Name |
Status |
Email |
Yaroslav M. |
lead |
ur.liam <<ta>> konlehc_la
|
License
Copyright (c) 2009 Yaroslav M.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Releases for sf 1.4
| Version |
License |
API |
Released |
|
1.1.1stable
|
MIT |
1.1.1stable
|
28/10/2010 |
Releases for sf 1.3
| Version |
License |
API |
Released |
|
1.1.1stable
|
MIT |
1.1.1stable
|
28/10/2010 |
Releases for sf 1.2
| Version |
License |
API |
Released |
|
1.1.1stable
|
MIT |
1.1.1stable
|
28/10/2010 |
|
0.1.0beta
|
MIT |
0.1.0beta
|
01/12/2009 |
Changelog for release 1.1.1 - 28/10/2010
Other releases
Release 1.1.1 - 28/10/2010
Release 0.1.0 - 01/12/2009
sfMCron plugin
The sfCron is a symfony plugin that provides a convenient work with cron.
This plugin allows to execute function & class methods according certain time specification.
With this plugin you can add, delete handlers, watch their list. Display priorities launch, monitor the work of handlers.
Installation
Create table in database
CREATE TABLE `sf_cron` (
`id` INTEGER(11) NOT NULL AUTO_INCREMENT,
`handler_spec` VARCHAR(255) COLLATE utf8_general_ci NOT NULL DEFAULT '',
`vars` TEXT COLLATE latin1_swedish_ci,
`exec_spec` VARCHAR(255) COLLATE utf8_general_ci NOT NULL DEFAULT '',
`start_process` DATETIME DEFAULT NULL,
`start_exec` DATETIME DEFAULT NULL,
`finish_exec` DATETIME DEFAULT NULL,
`exec_time` INTEGER(11) NOT NULL DEFAULT '0',
`active` TINYINT(1) NOT NULL DEFAULT '1',
`priority` INTEGER(11) NOT NULL DEFAULT '100',
`cdate` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`id`)
)ENGINE=MyISAM
AUTO_INCREMENT=11 CHARACTER SET 'utf8' COLLATE 'utf8_general_ci';
Add to cron
* * * * * user php /path_to_project/symfony --application=frontend cron:process
30 * * * * user php /path_to_project/symfony --application=frontend cron:check
Set your preferences in plugins/sfMCronPlugin/config/settings.yml
[yml]
all:
.settings:
# sfMCronPlugin
cron:
table: "sf_cron"
lock_name: "cron"
crash-time: 3600
mail_callable: "sfCron::sendAdminMail" # standart notify handler
mail_settings:
mailer: mail
charset: "utf-8"
sender: "test@test.ru"
from: "test@test.ru"
addReplyTo: "test@test.ru"
addAddress: "test1@test.ru"
Details
// execute handlers every minutes
// use table lock that the handler did not work in parallel
* * * * * user php /path_to_project/symfony cron:process
// check handlers and notify developers if handler did not work
30 * * * * user php /path_to_project/symfony cron:check
Use
Add handler:
$ symfony cron:add "MyClass->execHandler" "* * * * *"
$ symfony cron:add "MyClass->execHandlerA" "30 0 * * *"
Delete handler
$ symfony cron:remove "MyClass->execHandler" //delete all MyClass->execHandler handlers
$ symfony cron:remove "MyClass->execHandler" "* * * * *" //delete MyClass->execHandler handler with exec time * * * *
List of handlers
$ symfony cron:list
Debug
Own notify function
Call syntax
MyClass->execHandler //call method execHandler of class MyClass
MyUser->getSomeClass->execSomeHandler // get object from MyUser->getSomeClass() and exec method execSomeHandler
MyClass::execHandler //call static method execHandler of class MyClass
Synopsis:
// Add handler to cron table
sfCron::getInstance()->addHandler('MyClass->MyHandlerA', '24 * * * *', array("p1" => "v1", "p2" => "v2"));
sfCron::getInstance()->addHandler('MyClass::MyMethod', '* * * * *');
sfCron::getInstance()->addHandler('MyFunction', '* * * * *');
// Delete handler from cron table
sfCron::getInstance()->deleteHandler('MyClass->MyHandlerA');
sfCron::getInstance()->deleteHandler('MyLibrary.MyMethod', '* 10-18 * * *');
// Process all cron table
sfCron::getInstance()->process();
// Process one cron table record
sfCron::getInstance()->process($record_id);
// Process search for crashed handlers
// This function should be executed every 30 minutes, you need to add this function into the crontab file
sfCron::getInstance()->check();