From 1c582baa2c196c04b8069401178c5b2ea59a167c Mon Sep 17 00:00:00 2001 From: Jeroen De Meerleer Date: Sat, 15 Apr 2017 10:13:22 +0200 Subject: [PATCH] Added locking of the script --- webcron.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/webcron.php b/webcron.php index 8eafcd5..e2aed5f 100644 --- a/webcron.php +++ b/webcron.php @@ -26,6 +26,12 @@ require_once "include/initialize.inc.php"; +if(file_exists('cache/webcron.lock')) +{ + die('Script is already running'); +} +touch('cache/webcron.lock'); + $stmt = $db->query('SELECT jobID, url, delay, nextrun FROM jobs WHERE nextrun < ' . time()); $results = $stmt->fetchAll(PDO::FETCH_ASSOC); @@ -49,4 +55,6 @@ foreach ($results as $result) { } +unlink('cache/webcron.lock'); + require_once 'include/finalize.inc.php';