php cron jobs overlapping
- by naveen gupta
Hi I wrote few months back a script in perl for checking overlapping of jobs
use Fcntl ':flock';
INIT {
my $waitcount=12; # possible attemtps to run script
my $waitseconds=300; # wait for $waitseconds each attempt
my $lockstatus=0;#no lock was attained
while ($waitcount > 0){
if (open LH, $0){
while ($waitcount > 0){
if (flock LH, LOCK_EX|LOCK_NB){
$waitcount=0;#signal end of waiting
$lockstatus=1;#lock was attained
}
else{
--$waitcount;#decrement waitcount
print "waiting to be able to lock $0\n";
sleep $waitseconds;
}#end else
}#end while
}#end if
else{
--$waitcount;#decrement waitcount
print "waiting to be able to open $0\n";
sleep $waitseconds;
}#end else
}#end while
if ($lockstatus == 0){
die "no lock was attained\n";
}#end if
}
I wanted to know if we can do similar thing in php ..
How to integrate with your current php code which is running a part of php jobs?