diff --git a/shellscripts/cron_cache_gitbranches.php b/shellscripts/cron_cache_gitbranches.php
index 9e2c37e8b74413e8ee48df3831193c453a37207c..2b1a0257a642d63fe566b68ad1495c7a3f21983d 100644
--- a/shellscripts/cron_cache_gitbranches.php
+++ b/shellscripts/cron_cache_gitbranches.php
@@ -8,6 +8,7 @@
 
 // http://iml:deployment@ci.iml.unibe.ch/deployment/?prj=ci&action=deploy&par3=preview&confirm=1
 
+$iStart=date('U');
 $sDocroot = (dirname(__dir__)) . "/public_html";
 
 $processUser = posix_getpwuid(posix_geteuid());
@@ -15,6 +16,17 @@ if ($processUser['name']=="root"){
     die("Do not start the script as user root\n");
 };
 
+echo "\n<h1>===== IMLDEPLOYMENT - cache git branches :: ".(date("Y-m-d H:i:s"))." =====</h1>\n\n";
+$sLockfile="/tmp/cache-gitbranches.lock";
+if (file_exists($sLockfile)){
+    $iAge=date('U')-filemtime($sLockfile);
+    $iMagAge=60*60 * 3;
+    if ($iAge < 60*60 * 3){
+        die("ABORT: lock file exists: $sLockfile (age: $iAge sec ... needs to wait up to $iMagAge sec or the running script is finished)\n");
+    }
+    echo "INFO: ignoring existing lock file $sLockfile (age: $iAge sec is older $iMagAge sec)\n";
+}
+
 require_once("$sDocroot/deployment/classes/logger.class.php");
 global $oCLog;
 $oCLog = new logger();
@@ -25,7 +37,9 @@ require_once("$sDocroot/deployment/classes/project.class.php");
 
 $oPrj1 = new project();
 
-echo "<h1>===== IMLDEPLOYMENT - cache git branches =====</h1>\n";
+echo "creating lock file $sLockfile\n";
+file_put_contents($sLockfile, "started ".date("Y-m-d H:i:s"));
+
 foreach ($oPrj1->getProjects() as $sPrj) {
     $oPrj = new project($sPrj);
     
@@ -35,4 +49,9 @@ foreach ($oPrj1->getProjects() as $sPrj) {
     }
     echo "<br>\n";
 }
-echo "done\n";
+echo "\n\n---------- done\n";
+echo "removing lock file $sLockfile\n";
+unlink($sLockfile);
+echo "Script needed ".(date('U')-$iStart) . " s\n\n";
+
+// echo $oCLog->renderCli();
\ No newline at end of file