0
您好我寫了幾個月前的腳本在Perl檢查的工作重疊PHP cron作業重疊
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
}
我想知道,如果我們能做到在PHP中類似的事情..
如何整合與您正在運行的PHP作業的一部分目前的PHP代碼?