Added locking of the script

This commit is contained in:
Jeroen De Meerleer 2017-04-15 10:13:22 +02:00
parent 9258ca650b
commit 1c582baa2c
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6
1 changed files with 8 additions and 0 deletions

View File

@ -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';