Crontasks

dotAdmin has a simple task scheduler which runs every hour. You can attach new processes to the task scheduler by adding a new row to the `crontask` table of your site database:

crontask_name
This is the name of a class include located in SHARED_PATH/scripts/[crontask_name].crontask.class.php or APP_PATH/scripts/[crontask_name].crontask.class.php which will be run by this rule
crontask_frequency
The number of hours between each run of the task. eg: 24 means that the process runs once every 24 hours, 6 means it runs every 6 hours.
crontask_lastrun
When this rule was last run. It will next be run [crontask_frequency] after this datetime.
crontask_laststatus
The last status recorded when the process run: either "attempting", "in_progress", "success" or failed "failed"

The task include will be called [crontask_name].crontask.class.php, have a classname of [Crontask_name]CronTask, and must have a doTask() method. eg:

Class ExampleCronTask{

	protected $obj_db = null;
	
	public function __construct(){
		// Try get database
		$this->obj_db = InvDB::getDatabase('default');
	}
	
	public function doTask(){
		// do stuff here
		return true;
	}
}

Testing

You can test all crontasks by running:

/var/www/dotadmin/3.0/shared/scripts/crontasks.sh 3.0

You can test an individual site cron schedule by navigating to /var/www/dotadmin/3.0/shared/scripts and running:

php crontasks.php -- site=[sitename]

Contact Us

Address: 22a Fishergate York, YO10 4AB · Tel: 01904 636677 · Email: info@dotadmin.com