c**t 发帖数: 2744 | 1 下面这一段code在W2k3下运行一段时间就停止了(没有新的timestamp打印到stdout),
可能是怎么回事?
#!C:\perl\bin -w
use strict;
my ($t1, $t2, $dt);
my $DIR = 'C:\Scripts';
my $PHP = 'C:\PHP\php.exe';
my $SRC = 'getData.php';
my $INTERVAL = 3;
chdir($DIR);
my $i = 0;
while(1)
{
$t1 = time;
system($PHP, $SRC);
$t2 = time;
$dt = ($INTERVAL * 60) - ($t2 - $t1);
if($dt > 0)
{
print "[", scalar(localtime(time)), "] Sleeping $dt seconds\
n";
sleep( $dt );
|
t****t 发帖数: 6806 | 2 maybe system() hangs?
【在 c**t 的大作中提到】 : 下面这一段code在W2k3下运行一段时间就停止了(没有新的timestamp打印到stdout), : 可能是怎么回事? : #!C:\perl\bin -w : use strict; : my ($t1, $t2, $dt); : my $DIR = 'C:\Scripts'; : my $PHP = 'C:\PHP\php.exe'; : my $SRC = 'getData.php'; : my $INTERVAL = 3; : chdir($DIR);
|
w******p 发帖数: 166 | 3 my guess is here:
$dt = ($INTERVAL * 60) - ($t2 - $t1);
when it happens that $dt < 0
then sleep($dt) would convert the negative $dt into a really big one and it'
ll sleep there like forever, add this line
$dt = 1 if $dt < 1; |
c**t 发帖数: 2744 | 4 the sleep is inside if( $dt > 0) block, shall we still check $dt?
it'
【在 w******p 的大作中提到】 : my guess is here: : $dt = ($INTERVAL * 60) - ($t2 - $t1); : when it happens that $dt < 0 : then sleep($dt) would convert the negative $dt into a really big one and it' : ll sleep there like forever, add this line : $dt = 1 if $dt < 1;
|
c**t 发帖数: 2744 | 5 Could be php script issue. The system call never came back. I added set_time
_limit in the php script, it seems worked.
my guess is here:
$dt = ($INTERVAL * 60) - ($t2 - $t1);
when it happens that $dt < 0
then sleep($dt) would convert the negative $dt into a really big one and it'
ll sleep there like forever, add this line
$dt = 1 if $dt < 1;
【在 w******p 的大作中提到】 : my guess is here: : $dt = ($INTERVAL * 60) - ($t2 - $t1); : when it happens that $dt < 0 : then sleep($dt) would convert the negative $dt into a really big one and it' : ll sleep there like forever, add this line : $dt = 1 if $dt < 1;
|