在DB PHP脚本更新记录当脚本已运行超过30分钟

问题描述 投票:0回答:1

我有运行在每个晚上在我的数据库中更新记录的PHP脚本。在我的数据库我也有这个脚本记录:

文档名称

script1.php

完成

ñ

一旦脚本完成我做最后一次更新到数据库,这是更新“script1.php”并将其更改为“Y”

如果我删除一切在该文件中,除了对DB最后一次通话则脚本改变“N”到“Y”就好了。

问题是,作为标记完成之前,我得到记录,并将其插入到我的数据库这需要38分钟的总额。

这可能是我的问题,经过38分钟的脚本完成但是它不更新的“N”到“Y”。

upload_max_filesize = 256M
post_max_size = 256M
max_input_vars = 10000
memory_limit = 512M
max_execution_time = 3000

这些都是在服务器上的配置设置,我无法改变这些,因为这些已经是最大的设置即时通讯允许的。

虽然我得到一个504网关超时记录继续插入到数据库中。所有记录都完全插入然而这“N”心不是更改为“Y”。

我如何拿到剧本到足够长的时间来更新这个“N”运行到“Y”?

守则要求

<?php
// Run Script
require_once('removed');

ignore_user_abort(true); // just to be safe

echo('Script Started.');

flush();
// Do processing here

error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once('removed');
require('removed');
require('remvoed');

$filename = basename(__FILE__);
checkcrondependencies($filename);


//REMOVED DATA SUPPLIER CLASS

  date_default_timezone_set("Europe/London");


    $domainpath = realpath(dirname(__FILE__));
    $inipath = REMOVED;
    $privatepath = REMOVED;

    $connection_settings = REMOVED;
    $dbhost = $connection_settings['dbhost'];
    $dbname = $connection_settings['dbname'];
    $dbuser = $connection_settings['dbuser'];
    $dbpass = $connection_settings['dbpass'];

    //Make connection to supplier 


   $iscronfile = 'Y';

  $conn = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
  if (!$conn) {
      new_log_entry($filename,'DB Connection Failed','Y',$iscronfile);
      die("Connection failed: " . mysqli_connect_error());
  }

    // pull data from supplier 
    //push data to DB
    // Total time 38 minutes

     echo "completed";
     setcroncompleted($filename); // <<< THIS IS SUPPOSED TO CHANGE 'N' TO A 'Y'
     new_log_entry($filename,'Run Time End:'.date("Y-m-d h:i:sa"),'N',$iscronfile);
php mysql apache
1个回答
0
投票

脚本通过cron运行?使一些限制器限制脚本执行。你可以让cron来触发一个小时每一分钟,但登陆的地方,$ script_is_busy ==真,update_is_done =假。后限命中限制确保$ script_is_busy = FALSE和日志多远更新制成。一分钟后的下一个迭代的cron将继续更新。当更新完成日志$ update_is_done = TRUE ;.这不是大问题,如果cron的火灾“空素文字”一样,如果unpdate_is_dome ==是真的吗?死()。

© www.soinside.com 2019 - 2024. All rights reserved.