负担不大的话就先这样吧。10秒对于服务器来说根本没影响。
或者使用php-cli模式。php脚本写成这样:<?php
while (true) {
sleep(10);
dofunction();
}
?>然后在cmd里面
php run.php
或者使用php-cli模式。php脚本写成这样:<?php
while (true) {
sleep(10);
dofunction();
}
?>然后在cmd里面
php run.php
解决方案 »
- 关于页面之间大量传递数据的问题
- uploadify上传原理分析-分块上传还是传统上传
- 在prototype调用服务端程序a.php ,如何设置cookie和session
- smarty提供的html_option如何增加一个option选项?
- XAMPP集成包作为上线环境报错!!求解决。
- PHP如何删除文本文件中的一行?
- 做过PHP扩展模块的高手来看看!!!!!!!!!!
- 请各位大虾说一下oracle函数中,ocifetchinto的具体用法?
- Fatal error: Call to a member function fetch_array() on a non-object in 62 line
- 怎么运行PHP文件
- 史上最牛B的缩放图width/XXX/height/XXX (XXX是数值) ,就可以得到不同的大小的图片,求解
- 大家说这两个sql语句哪个快?
我是这样10秒刷新一次WEB页面的,运行一段时间就卡:
<script>
var limit="0:10"
if (document.images){
var parselimit=limit.split(":")
parselimit=parselimit[0]*60+parselimit[1]*1}
function beginrefresh(){
if (!document.images)
return
if (parselimit==1)
window.location.reload()
else{
parselimit-=1
curmin=Math.floor(parselimit/60)
cursec=parselimit%60
if (curmin!=0)
curtime=curmin+"分"+cursec+"秒后重刷本页!"
else
curtime=cursec+"秒后重刷本页!"
window.status=curtime
setTimeout("beginrefresh()",1000)
}}
window.onload=beginrefresh
</script>
将这个网页打开就行了
或者在meta 里写refresh=10
这样的话,发送、接收到什么信息都可以清楚地看到并进行相应的操作。lz可以用PHP做一个HTTP客户程序就可以了。
浏览器是给人看的,你这种方式效率太低了,而且基本也无法实现你要做的事情。
http://framework.zend.com/manual/zh/zend.http.html
而php脚本可以通过cli方式运行。
比如:c:\php5\php.exe d:\myprj\myscript.php我记得它的定时功能挺强的,不过不确定是否能精确到秒级。
其实最有效的方法还是前面说的,延时后循环操作比较实际:while (1) {
doMyAction();
sleep(10);
}但由于服务器可能重启或者是脚本可能会错误退出,还需要另外有机制检查脚本是否在运行,不在运行则再次运行。 linux下grep一下就可以。 php下可能要通过文件锁之类的形式来实现。
Why don't u run the script from the command line on the server.It really has nothing to do with the browser if php is your only available choice.