php cron jobs overlapping
Posted
by
naveen gupta
on Stack Overflow
See other posts from Stack Overflow
or by naveen gupta
Published on 2011-06-29T07:19:03Z
Indexed on
2011/06/29
8:22 UTC
Read the original article
Hit count: 202
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?
© Stack Overflow or respective owner