doumie7914 2016-08-08 13:13
浏览 290

php file_get_contents执行两次

I have created a script to check in backup tapes into our tape library and check them in with TSM. This script is activated by SMS.

Our SMS server receives the command to start the check-in and then executes a script on the TSM server with a file_get_contents command.

I have an issue that the script is being executed twice when there are allot of tapes to check in(+20). This results errors on out TSM server because the move media commands are allso double.

I overcame this by putting in an inital timestamp logging when the first file_get_content is started so the commands arent executed twice. Allthough this fixes the double command issue it still presents a problem because the SMS server sends back confirmation that the script started or not. So this means that on every check in with +20 tapes, the operator gets 2 messages, 1 saying check in failed, the other check in started.

I suspect this is caused because of the time it takes for the commands to be passed onto the TSM server (can take upto 45seconds).

Long story short, is there a way i can set some sort of longer timeout, or give any parameter/checks to prevent this behaviour? Thanks in advance. Paths are replaced by *****.

SMS server code
    //DRM checkin
            if($auth == 1 AND strtolower($sms_body) == "******"){
                $knowncommand = 1;
                $url = "http://*******/******/checkin.php?remote&exec&sender=" . $from;
                $dodrm = file_get_contents($url);
                if ($stmt2 = $mysqli->prepare("UPDATE messagein SET checked = 1 WHERE checked = 0 ")) {
                    $stmt2->execute();
                    $stmt2->close();
                }
            }

TSM Server script code:

if(isset($_GET['exec'])){
    if(isset($_GET['remote'])){
        $rcs = CheckRemoteCheckinStatus();
        $to = $_GET['sender'];
        //Execute drm check-in
        $commit = CheckButtonStatus();
        if($commit == "" AND $rcs == 0){
            SetRemoteCheckinStatus();
            $psDIR = "*****";
            $psScript = "drm_checkin_retrieve.ps1";
            $runCMD = $psPath. ' -ExecutionPolicy RemoteSigned '.$psDIR.$psScript;
            exec($runCMD, $out);
            SetCheckinStatus();
            $psDIR = "*****";
            $psScript = "QueueSMS.ps1 $to 'Check-in gestart...'";
            $runCMD = $psPath. ' -ExecutionPolicy RemoteSigned '.$psDIR.$psScript;
            exec($runCMD, $out);
        }
        else{
            //Send Failed SMS
            $psDIR = "*****";
            $psScript = "QueueSMS.ps1 $to 'Fout: Geen Check-in mogelijk.'";
            $runCMD = $psPath. ' -ExecutionPolicy RemoteSigned '.$psDIR.$psScript;
            exec($runCMD, $out);
        }
    }
    else{
        $psDIR = "*******";
        $psScript = "drm_checkin_retrieve.ps1";
        $runCMD = $psPath. ' -ExecutionPolicy RemoteSigned '.$psDIR.$psScript;
        exec($runCMD, $out);
        echo "Check-in gestart...<br><br>";
        SetCheckinStatus();
    }
}
  • 写回答

1条回答 默认 最新

  • dsw1608 2016-08-08 14:21
    关注

    If you have access to your php.ini, this topic can be usefull

    If you want to increase your timeout only in a specific script, you can use set_time_limit

    Or another way, at the beginning of your php script :

    ini_set('max_execution_time', 120); //120 seconds
    
    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题