2007-07-19 12:40:28 +02:00
|
|
|
<?php
|
2008-02-25 03:10:37 +01:00
|
|
|
/**
|
2008-12-01 02:15:27 +01:00
|
|
|
* Abstract task representing scheudled tasks.
|
2010-10-15 05:55:22 +02:00
|
|
|
*
|
|
|
|
* Scheduled tasks are tasks that are run at a certain time or set interval. For example, notify a page owner that
|
|
|
|
* their page is about to expire. Scheduled tasks are implemented as singleton instances and a single
|
|
|
|
* instance is responsibly directly or indirectly for executing all tasks that should be run at that time.
|
|
|
|
*
|
2008-12-01 02:15:27 +01:00
|
|
|
* You can use the different subclasses {@link HourlyTask}, {@link DailyTask},
|
|
|
|
* {@link WeeklyTask} to determine when a task should be run,
|
|
|
|
* and use automation tools such as unix cron to trigger them.
|
|
|
|
*
|
2010-10-15 05:55:22 +02:00
|
|
|
* <b>Usage</b>
|
|
|
|
*
|
|
|
|
* Implement a daily task by extending DailyTask and implementing process().
|
|
|
|
*
|
|
|
|
* <code>
|
|
|
|
* class MyTask extends DailyTask {
|
|
|
|
* function process() {
|
|
|
|
* // implement your task here
|
|
|
|
* }
|
|
|
|
* }
|
|
|
|
* </code>
|
|
|
|
*
|
|
|
|
* You can also implement the index() method to overwrite which singleton classes are instantiated and processed.
|
|
|
|
* By default, all subclasses of the task are instantiated and used. For the DailyTask class, this means
|
|
|
|
* that an instance of each subclass of DailyTask will be created.
|
|
|
|
*
|
|
|
|
* You can test your task from the command line by running the following command
|
|
|
|
* (replace <MyTask> is the classname of your task):
|
|
|
|
*
|
2012-03-24 04:38:57 +01:00
|
|
|
* <code>framework/cli-script.php /<MyTask></code>
|
2010-10-15 05:55:22 +02:00
|
|
|
*
|
|
|
|
* To perform all Daily tasks, run from the command line:
|
|
|
|
*
|
|
|
|
* <code>cli-script.php /DailyTask</code>
|
|
|
|
*
|
|
|
|
* <b>Example Cron Definition</b>
|
|
|
|
*
|
2008-12-01 02:15:27 +01:00
|
|
|
* <code>
|
2009-08-18 00:30:27 +02:00
|
|
|
* # Quarter-hourly task (every hour at 25 minutes past) (remove space between first * and /15)
|
2012-03-24 04:38:57 +01:00
|
|
|
* * /15 * * * * www-data /my/webroot/framework/cli-script.php /QuarterlyHourlyTask > /var/log/silverstripe_quarterhourlytask.log
|
2009-08-18 00:30:27 +02:00
|
|
|
*
|
2008-12-01 02:15:27 +01:00
|
|
|
* # HourlyTask (every hour at 25 minutes past)
|
2012-03-24 04:38:57 +01:00
|
|
|
* 25 * * * * www-data /my/webroot/framework/cli-script.php /HourlyTask > /var/log/silverstripe_hourlytask.log
|
2008-12-01 02:15:27 +01:00
|
|
|
*
|
|
|
|
* # DailyTask (every day at 6:25am)
|
2012-03-24 04:38:57 +01:00
|
|
|
* 25 6 * * * www-data /my/webroot/framework/cli-script.php /DailyTask > /var/log/silverstripe_dailytask.log
|
2008-12-01 02:15:27 +01:00
|
|
|
*
|
|
|
|
* # WeelkyTask (every Monday at 6:25am)
|
2012-03-24 04:38:57 +01:00
|
|
|
* 25 6 1 * * www-data /my/webroot/framework/cli-script.php /WeeklyTask > /var/log/silverstripe_weeklytask.log
|
2008-12-01 02:15:27 +01:00
|
|
|
* </code>
|
|
|
|
*
|
2008-03-03 00:24:10 +01:00
|
|
|
* @todo Improve documentation
|
2008-02-25 03:10:37 +01:00
|
|
|
* @package sapphire
|
|
|
|
* @subpackage cron
|
|
|
|
*/
|
2007-07-19 12:40:28 +02:00
|
|
|
abstract class ScheduledTask extends CliController {
|
2010-05-25 04:58:59 +02:00
|
|
|
// this class exists as a logical extension
|
2012-03-24 04:38:57 +01:00
|
|
|
}
|