【发布时间】:2012-06-24 05:31:07
【问题描述】:
我正在尝试在我的基于 linux 的服务器上运行这个 php 脚本。
$today = strtotime("today");
$tommorow = date("Y-m-d", strtotime("+1day",$today));
$today = date("Y-m-d");
//Endless loop because the data here updates around the clock
while(1){
while (time() <= strtotime("$tommorw 8:00PM")){
sleep(30);
flush();
}
}//end 24 h loop
//save the file as a date file and delete it's content
//move on to the next day
$today = strtotime("today");
$tommorow = date("Y-m-d", strtotime("+1day",$today));
}//end of endless loop
如果我从一个简单的浏览器运行它就可以正常工作(当然当我关闭它时它会停止工作)。
我正在尝试通过 perl 脚本运行它
chdir("mydir");
exec('indices.php'); #tryed also system("php indices.php");
然后像这样运行 perl 脚本
./PROMadadim.pl >> ./PROMadadim.log &
但是当我尝试从服务器运行它时它不起作用。
【问题讨论】:
-
它被称为守护进程,google "php Daemon"
-
为什么说“它不起作用”?具体会发生什么?它是否正在运行但功能不正确?它根本不运行吗(
ps -A什么也没有显示)? -
设置一个 cron 作业。几乎不建议使用无限循环。