From a4e127a6af97041b2c067f888f8c73a8aec682f1 Mon Sep 17 00:00:00 2001
From: Marius Burkard <m.burkard@pixcept.de>
Date: Mon, 04 Jan 2016 05:29:53 -0500
Subject: [PATCH] Merge branch 'mergebranch' into 'master'
---
server/lib/classes/cronjob.inc.php | 31 +++++++++++++++++++++++++++----
1 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/server/lib/classes/cronjob.inc.php b/server/lib/classes/cronjob.inc.php
index 03e36e7..02f4f46 100644
--- a/server/lib/classes/cronjob.inc.php
+++ b/server/lib/classes/cronjob.inc.php
@@ -47,7 +47,30 @@
public function getSchedule() {
- return $this->_schedule;
+ global $app, $conf;
+
+ $class = get_class($this);
+
+ switch ($class) {
+ case 'cronjob_backup':
+ $app->uses('ini_parser,getconf');
+ $server_id = $conf['server_id'];
+ $server_conf = $app->getconf->get_server_config($server_id, 'server');
+ if(isset($server_conf['backup_time']) && $server_conf['backup_time'] != ''){
+ list($hour, $minute) = explode(':', $server_conf['backup_time']);
+ $schedule = $minute.' '.$hour.' * * *';
+ } else {
+ $schedule = '0 0 * * *';
+ }
+ break;
+ /*case 'cronjob_backup_mail':
+ $schedule = '1 0 * * *';
+ break;*/
+ default:
+ $schedule = $this->_schedule;
+ }
+
+ return $schedule;
}
@@ -56,7 +79,7 @@
public function run() {
print "Called run() for class " . get_class($this) . "\n";
- print "Job has schedule: " . $this->_schedule . "\n";
+ print "Job has schedule: " . $this->getSchedule() . "\n";
$this->onPrepare();
$run_it = $this->onBeforeRun();
if($run_it == true) {
@@ -86,7 +109,7 @@
if($this->_run_at_new == true) {
$this->_next_run = ISPConfigDateTime::dbtime(); // run now.
} else {
- $app->cron->parseCronLine($this->_schedule);
+ $app->cron->parseCronLine($this->getSchedule());
$next_run = $app->cron->getNextRun(ISPConfigDateTime::dbtime());
$this->_next_run = $next_run;
@@ -116,7 +139,7 @@
// next_run time reached (reached === 0 or -1)
// calculare next run time based on last_run or current time
- $app->cron->parseCronLine($this->_schedule);
+ $app->cron->parseCronLine($this->getSchedule());
if($this->_no_skip == true) {
// we need to calculare the next run based on the previous next_run, as we may not skip one.
$next_run = $app->cron->getNextRun($this->_next_run);
--
Gitblit v1.9.1