From b6027e91177981d5ae013669e6b9718e37103145 Mon Sep 17 00:00:00 2001 From: VereschakSun <31344084+VereschakSun@users.noreply.github.com> Date: Sat, 25 Jan 2020 11:53:42 +0200 Subject: [PATCH] Update Jobby.php --- src/Jobby.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Jobby.php b/src/Jobby.php index 53858af..dd6489a 100644 --- a/src/Jobby.php +++ b/src/Jobby.php @@ -143,6 +143,11 @@ public function add($job, array $config) $config = array_merge($this->config, $config); $this->jobs[] = [$job, $config]; } + + + private function isProcessRunning($name){ + return shell_exec('ps aux | grep "'.$name.'" | grep -v grep | awk \'{ print $2 }\' | head -1'); + } /** * Run all jobs. @@ -162,6 +167,11 @@ public function run() continue; } if ($isUnix) { + $lockFile = "/tmp/$job.lck"; + if(empty($this->isProcessRunning($this->helper->escape($job)))){ + unlink($lockFile); + } + $this->runUnix($job, $config); } else { $this->runWindows($job, $config);