在本地apache下超过20分钟后会触发register_shutdown_function设置的函数,可是在服务器的IIS下却不行,请问是怎么回事?如何解决?

解决方案 »

  1.   

    有的20分钟,不过apache应该也有这种机制吧,可是为什么apache下可以触发呢
      

  2.   

    register_shutdown_function是程序停止就执行。
    你说的超过20分钟什么意思???
      

  3.   

    <?php
    ignore_user_abort();
    set_time_limit(0);
    require_once 'create_TXT_on.php';
    $i = 0;
    function shutdown(){
    $makehtmlfile = fopen("D:/PHP/123/stop2.txt","w");
    $iscreateHTML = fwrite($makehtmlfile,'1');
    fclose($makehtmlfile);
    die('已停止');
    }
    register_shutdown_function('shutdown');
    $nb = new adfg();
    while(true){
    require('create_TXT_on.php');
    if($ison == 0){
    $makehtmlfile = fopen("123/stop1.txt","w");
    $iscreateHTML = fwrite($makehtmlfile,'1');
    fclose($makehtmlfile);
    die('已停止');
    }
    sleep(5);
    $makehtmlfile = fopen("123/$i.txt","w");
    $iscreateHTML = fwrite($makehtmlfile,'1');
    fclose($makehtmlfile);
    $i++;
    }
    ?>create_TXT_on.php 里面就一行$ison == 1;
      

  4.   

    怎么说呢?
    按你的代码,除非用户关闭浏览器,程序会一直运行下去。
    在你的代码中一直没有输出(除了不会执行到的die),这就可能使得web服务器因长时间没有数据返回而强制终止程序的运行
      

  5.   

    这个程序我在shutdown函数中加了用fsockopen再次调用此页面,在apache中  可以一直运行着  我测试过,执行一天都没问题。可是在IIS下 好像就因为超时问题停止了,停止的时候shutdown根本没有被调用,因为没声生成txt