| | |
| | | |
| | | |
| | | 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; |
| | | } |
| | | |
| | | |
| | |
| | | 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) { |
| | |
| | | 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; |
| | | |
| | |
| | | // 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); |