diff options
Diffstat (limited to 'modules-available/rebootcontrol/hooks')
-rw-r--r-- | modules-available/rebootcontrol/hooks/cron.inc.php | 27 |
1 files changed, 1 insertions, 26 deletions
diff --git a/modules-available/rebootcontrol/hooks/cron.inc.php b/modules-available/rebootcontrol/hooks/cron.inc.php index c1136c98..8f5c73a0 100644 --- a/modules-available/rebootcontrol/hooks/cron.inc.php +++ b/modules-available/rebootcontrol/hooks/cron.inc.php @@ -11,32 +11,7 @@ if (in_array((int)date('G'), [6, 7, 9, 12, 15]) && in_array(date('i'), ['00', '0 } // CRON for Scheduler -$now = time(); -$res = Database::simpleQuery("SELECT s.locationid, s.action, s.nextexecution, s.options, l.openingtime - FROM reboot_scheduler s - INNER JOIN location l USING (locationid) - WHERE s.nextexecution <= :now", ['now' => $now]); -while ($row = $res->fetch(PDO::FETCH_ASSOC)) { - $options = json_decode($row['options'], true); - - // Calculate next_execution for the event. - Scheduler::updateSchedule($row['locationid'], $options, $row['openingtime']); - - if ($row['nextexecution'] + 1200 < $now) - continue; - - $machines = Database::queryAll("SELECT machineuuid, clientip, macaddr, locationid FROM machine - WHERE locationid = :locid", ['locid' => $row['locationid']]); - if ($row['action'] === Scheduler::SHUTDOWN) { - RebootControl::execute($machines, RebootControl::SHUTDOWN, 0); - } elseif ($row['action'] === Scheduler::WOL) { - RebootControl::wakeMachines($machines); - } elseif ($row['action'] === Scheduler::REBOOT) { - RebootControl::execute($machines, RebootControl::REBOOT, 0); - } else { - EventLog::warning("Invalid action '{$row['action']}' in schedule for location " . $row['locationid']); - } -} +Scheduler::cron(); /* * Client reachability test -- can be disabled |