Skip to content
Snippets Groups Projects
Commit a2199317 authored by Till Brehm's avatar Till Brehm
Browse files

Revert "Improved cron debug script"

This reverts commit b34b1ad5.

Fixes #5657
parent 0aa4f2de
No related branches found
No related tags found
No related merge requests found
......@@ -39,25 +39,20 @@ ini_set('error_reporting', E_ALL & ~E_NOTICE);
$conf['server_id'] = intval($conf['server_id']);
// Load required base-classes
$app->uses('ini_parser,file,services,getconf,system,cron,functions');
$app->uses('modules,plugins,ini_parser,file,services,getconf,system,cron,functions');
$app->load('libdatetime,cronjob');
// Path settings
$path = SCRIPT_PATH . '/lib/classes/cron.d';
//** Get commandline options
$cmd_opt = getopt('', array('cronjob::', 'force', 'firstrun'));
$cmd_opt = getopt('', array('cronjob::'));
if(isset($cmd_opt['cronjob']) && is_file($path.'/'.$cmd_opt['cronjob'])) {
// Cronjob that shell be run
$cronjob_file = $cmd_opt['cronjob'];
} else {
echo "Usage example: php cron_debug.php --cronjob=100-mailbox_stats.inc.php [--force] [--firstrun]\n" ;
echo "Available cronjobs:\n";
foreach(glob($path.'/*-*.inc.php') as $cronjob) {
echo basename($cronjob)."\n";
}
die();
die('Usage example: php cron_debug.php --cronjob=100-mailbox_stats.inc.php');
}
// Load and run the cronjob
......@@ -66,20 +61,8 @@ if(preg_match('/^\d+\-(.*)$/', $name, $match)) $name = $match[1]; // strip numer
include $path . '/' . $cronjob_file;
$class_name = 'cronjob_' . $name;
$cronjob = new $class_name();
if(isset($cmd_opt['force'])) {
$app->db->query("UPDATE `sys_cron` SET `running` = 0 WHERE `name` = ?", $class_name);
}
$cronjob->onPrepare();
$cronjob->onBeforeRun(isset($cmd_opt['firstrun']));
if(!$cronjob->isRunning()) {
$app->db->query("UPDATE `sys_cron` SET `running` = ? WHERE `name` = ?", ($cronjob->canBeRunInParallel() !== true ? "1" : "0"), $class_name);
$cronjob->onRunJob();
$cronjob->onAfterRun();
$cronjob->onCompleted();
}
$cronjob->run(true);
die("finished.\n");
?>
\ No newline at end of file
?>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment