summaryrefslogtreecommitdiffstats
path: root/modules-available/rebootcontrol/hooks/cron.inc.php
diff options
context:
space:
mode:
Diffstat (limited to 'modules-available/rebootcontrol/hooks/cron.inc.php')
-rw-r--r--modules-available/rebootcontrol/hooks/cron.inc.php16
1 files changed, 6 insertions, 10 deletions
diff --git a/modules-available/rebootcontrol/hooks/cron.inc.php b/modules-available/rebootcontrol/hooks/cron.inc.php
index 5ae3b1c8..56446c49 100644
--- a/modules-available/rebootcontrol/hooks/cron.inc.php
+++ b/modules-available/rebootcontrol/hooks/cron.inc.php
@@ -12,25 +12,21 @@ 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 * FROM reboot_scheduler WHERE nextexecution < :now", ['now' => $now]);
+$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.
- $location = Database::queryFirst("SELECT openingtime FROM `location`
- WHERE locationid = :lid", ['lid' => $row['locationid']]);
- Scheduler::updateSchedule($row['locationid'], $options, $location['openingtime']);
+ Scheduler::updateSchedule($row['locationid'], $options, $row['openingtime']);
if ($row['nextexecution'] + 1200 < $now)
continue;
- $machinedb = Database::simpleQuery("SELECT machineuuid, clientip, macaddr, locationid FROM machine
+ $machines = Database::queryAll("SELECT machineuuid, clientip, macaddr, locationid FROM machine
WHERE locationid = :locid", ['locid' => $row['locationid']]);
- $machines = [];
- while ($machine = $machinedb->fetch(PDO::FETCH_ASSOC)) {
- settype($machine['locationid'], 'int');
- $machines[] = $machine;
- }
if ($row['action'] === 'sd') {
RebootControl::execute($machines, RebootControl::SHUTDOWN, 0);
} elseif ($row['action'] === 'wol') {