Version 9 (modified by Tomtom33, 15 years ago) (diff) |
---|
dcCron
Schedule any tasks
Author/Contributors?
- Author: Tomtom33
- Contributors:
Development
Bugs and features requests
Repository
Recent Changes
[2656] by Tomtom33 on 09/21/10 12:33:53
dcCron:
- Updated link with dcLog plugin
- Updated CSS class for tasks list
[2654] by Tomtom33 on 09/21/10 11:28:34
dcCron 2.0-RC2:
- Exception management for check() function
- Improved filters
- Improved UI
[2650] by Tomtom33 on 09/20/10 20:06:11
dcCron 2.0-RC1:
- Lock file support
- Fixed date concurrency
- Improved tasks check
- Improved UI
Documentation
dcCron is a generic plugin can be called by others to schedule tasks. It provides a simply API to use it.
Add / Modify task
To add a task in dcCron, just put this in your code :
if (isset($core->blog->dcCron)) { $core->blog->dcCron->put('taskNameId','interval','callback'); }
- taskNameId must be an alphanumeric string. That's means just contains letters and numbers.
- interval supports two datas formats:
- interger. Second is the unit.
- string like a crontab format but simplified : [hour] [minutes] [day] [month].
You can use caracter [*] for repetitions. For examples :- Task will be execute every day at 2AM
02 00 * *
- Task will be execute each first day of month at 6.30AM
06 30 01 *
- Task will be execute each hour past 5 minutes
05 * * *
- Task will be execute every day at 2AM
- callback must be an array with class name or object in first argument and function in second. Function used for callback must be a static method. You can not specify an object.
If a task is already defined, function will update task with new parameters and execute the callback. If one or more parameters are invalid, function will generate exceptions displayed like errors in admin interface with prefix [dcCron].
Delete on or more tasks
To delete tasks just put this in your code :
if (isset($core->blog->dcCron)) { $array = array( 'taskNameId1', 'taskNameId2', ... $core->blog->dcCron->del($array); }
- $array must be an array containning tasks names id. These task names id must be an alphanumeric string. That's means just contains letters and numbers.
Verify if task exists
To verify if task exists or not, just put this code :
if ($core->blog->dcCron->taskExists('taskNameId')) { # Task exists at this point }
- taskNameId must be a valide task name id.
Enable / Disable task
To enable / disable task, just put this code :
if (isset($core->blog->dcCron)) { # To enable task $core->blog->dcCron->enable('taskNameId'); # To disable task $core->blog->dcCron->disable('taskNameId'); }
- taskNameId must be a valide task name id. If not, an exception will be generated.
Disabled task won't be execited even if interval is exceeded. It's can be usefull for tests or integration in other plugins.
Attachments
-
plugin-dcCron-lastest.zip
(19.5 KB) - added by Tomtom33 14 years ago.