gpt4 book ai didi

php file_get_contents 执行两次

转载 作者:搜寻专家 更新时间:2023-10-31 21:52:34 25 4
gpt4 key购买 nike

我已经创建了一个脚本来将备份磁带 checkin 我们的磁带库并使用 TSM checkin 它们。此脚本由短信激活。

我们的 SMS 服务器接收开始 checkin 的命令,然后使用 file_get_contents 命令在 TSM 服务器上执行脚本。

我有一个问题,当有分配的磁带要 checkin (+20) 时,脚本被执行了两次。这会导致 TSM 服务器出错,因为移动媒体命令都是双倍的。

我通过在第一个 file_get_content 启动时放入一个初始时间戳记录来克服这个问题,这样命令就不会执行两次。虽然这修复了双命令问题,但它仍然存在问题,因为 SMS 服务器发回确认脚本是否启动。所以这意味着每次使用 +20 个磁带进行 checkin 时,运算符(operator)都会收到 2 条消息,其中一条表示 checkin 失败,另一条 checkin 开始。

我怀疑这是因为将命令传递到 TSM 服务器所花费的时间(最多可能需要 45 秒)。

长话短说,有没有办法可以设置某种更长的超时,或者提供任何参数/检查来防止这种行为?提前致谢。路径由 ***** 替换。

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 服务器脚本代码:

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();
}
}

最佳答案

如果您有权访问您的 php.ini,这 topic可能会有用

如果你只想增加特定脚本的超时时间,你可以使用 set_time_limit

或者换一种方式,在你的 php 脚本的开头:

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

关于php file_get_contents 执行两次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38830173/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com