我想在我的基于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 &
但是当我尝试从服务器运行它时,它不起作用。
答案 0 :(得分:2)
通过查看代码,您最好设置一个CRON作业。如果您的服务器不支持CRON,那么您可以尝试添加...
set_time_limit(0);
或尝试将-q添加到php命令中,如下所示:
php -q /home/user/example.php