Don't run cron job if already running

Solution 1:

Use a bash script as your cron job

cron.sh

#!/bin/bash
$lockfile=/tmp/lock.file

if [ ! -e $lockfile ]; then
   touch $lockfile
   php /path/to/php/script.php
   rm $lockfile
else
   echo "script already running"
fi

Solution 2:

Please see Process Management. You will probably want to use a lock file. You can use flock for example.

Why can't you let your jobs complete?

Your questions says "I either didn't understand the answer or it didn't apply to me", but you don't say in what way. Please be more specific.

Tags:

Linux

Php

Cron