function _hosting_setup_cron in Hosting 6.2
Same name and namespace in other branches
- 5 hosting.module \_hosting_setup_cron()
- 7.4 hosting.module \_hosting_setup_cron()
- 7.3 hosting.module \_hosting_setup_cron()
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 ./
hosting.module - Initial hosting setup drush command.
File
- ./
hosting.module, line 484 - 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(dt("Replacing existing crontab"), 'warning');
}
else {
drush_log(dt("No existing crontab was found"), 'message');
}
$cron = hosting_queues_cron_cmd();
$fp = popen('crontab -', 'w');
$success = TRUE;
if ($fp) {
if (fwrite($fp, $cron) && fwrite($fp, "\n")) {
drush_log(dt("Installed hosting-dispatch cron entry to run every minute"), 'success');
}
else {
$success = FALSE;
}
// pclose returns shell exit codes (ie. 0 is success)
if (pclose($fp)) {
$success = FALSE;
}
}
else {
$success = FALSE;
}
if (!$success) {
drush_set_error('PROVISION_CRON_FAILED', dt('Failed to install cron job'));
}
}