function _hosting_setup_cron in Hostmaster (Aegir) 6
Set up the hosting-dispatch command in the aegir user's crontab.
Replace the crontab entry if it exists, else create it from scratch.
1 call to _hosting_setup_cron()
- drush_hosting_setup in modules/
hosting/ hosting.module - Initial hosting setup drush command.
File
- modules/
hosting/ hosting.module, line 457 - Hosting module.
Code
function _hosting_setup_cron() {
$existing = FALSE;
exec('crontab -l 2> /dev/null', $cron);
variable_set('hosting_cron_backup', $cron);
if (sizeof($cron)) {
drush_log("Your existing cron entry will be replaced.", 'warning');
exec('crontab -r 2> /dev/null');
$cron = array();
}
else {
drush_log(dt("No existing crontab was found"), 'message');
}
$cron[] = hosting_queues_cron_cmd();
$tmpnam = tempnam('hostmaster', 'hm.cron');
$fp = fopen($tmpnam, "w");
foreach ($cron as $line) {
fwrite($fp, $line . "\n");
}
fclose($fp);
system(sprintf('crontab %s', escapeshellarg($tmpnam)));
unlink($tmpnam);
drush_log(dt("Installed hosting-dispatch cron entry to run every minute"), 'message');
return null;
}