Skip to content

Latest commit

 

History

History
36 lines (27 loc) · 832 Bytes

README.md

File metadata and controls

36 lines (27 loc) · 832 Bytes

Silverstripe Pseudo Cron

Implements a cron like system triggered by page requests. Jobs are executed asynchronously so page load times aren't affected.

Usage

Add a job to the CronTab. This should only be done once. Maybe in a requireDefaultRecords() function.

CronTab::add(array(
	'Name' => 'Garbage collector',
	'Callback' => array('GarbageCollector','collect'),
	'Increment' => 600, // 10 mins
	'Description' => 'Take out the trash.',
	'Notify' => '[email protected]' // Notifies only when something goes wrong.
));

Give the CronTab something to call:

class GarbageCollector extends Controller {
	public static function collect() {
		// Take out the trash.
	}
}

Requirements

  • Silverstripe 3.0.3+

A 2.4.x compatible version is available in the 2.4 branch.