From cbf83d3fc91f4a1fc3a88bc9b624bf55fa336f0e Mon Sep 17 00:00:00 2001 From: Till Brehm Date: Tue, 26 Jul 2016 17:36:42 +0200 Subject: [PATCH] Added debug script for ISPConfig cronjob debugging. --- server/cron_debug.php | 72 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 server/cron_debug.php diff --git a/server/cron_debug.php b/server/cron_debug.php new file mode 100644 index 000000000..615a56d74 --- /dev/null +++ b/server/cron_debug.php @@ -0,0 +1,72 @@ +uses('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::')); + +if(isset($cmd_opt['cronjob']) && is_file($path.'/'.$cmd_opt['cronjob'])) { + // Cronjob that shell be run + $cronjob_file = $cmd_opt['cronjob']; +} else { + die('Usage example: php cron_debug.php --cronjob=100-mailbox_stats.inc.php'); +} + +// Load and run the cronjob +$name = substr($cronjob_file, 0, strpos($cronjob_file, '.')); +if(preg_match('/^\d+\-(.*)$/', $name, $match)) $name = $match[1]; // strip numerical prefix from file name +include $path . '/' . $cronjob_file; +$class_name = 'cronjob_' . $name; +$cronjob = new $class_name(); + +$cronjob->onPrepare(); +$cronjob->onBeforeRun(); +$cronjob->onRunJob(); +$cronjob->onAfterRun(); + +die("finished.\n"); + +?> -- GitLab