douhong1703 2015-06-03 11:10
浏览 63
已采纳

php打印出“终止”,终端没有任何错误

I have this script that is supposed to read a big csv file and insert the contents into database(mysql). I am running the script from terminal ie php index.php however after some time the script prints out Terminated and stops running without any reasonable error. I have added all these to the script but still can't get it to finish exacution: set_time_limit(0); ignore_user_abort() ; ini_set('memory_limit','5120M'); Below is a snipet of the code.NB I have just picked a small bit of it.

<?php
set_time_limit(0);
ignore_user_abort() ;
ini_set('memory_limit','5120M');
echo ini_get("memory_limit")."
";
$conn = new mysqli("dbase1", "apps", "t3ck", "transactional");
$files = array("/home/username/mycsv.csv");
foreach($files as $file){
    echo "----------------------------------------------------------------------------------$file--------------------------------------------
";
    $rows = array_map('str_getcsv', file($file));
    $csv = array();
    $array = explode(".",$file);
    $name = $array[0];
    //$service = getserviceId($name);

    foreach ($rows as $row) {
        $conn->query("INSERT INTO transactions (foreign_key, model, created, modified) VALUES (NULL, NULL, now(), now());");
        $count = $conn->insert_id;
        echo "TRX id: $count 
";
        $no= $row[0];
        $net = "FDO";
        $query = "insert ignore into text_gf services_id,no,net,sub_date,transactions_id,created,last_delivery_date) VALUES(118,$no,$net,now(),$count,now(),now())";
        $res =$conn->query($query);

        if($res) {
            echo "$msisdn saved  
";
        } else {
            print_r($conn->error);
            die();
        }
    }
unlink($file);
}
  • 写回答

3条回答 默认 最新

  • doukougua7873 2015-06-03 13:48
    关注

    Am sorry for this stupid question. Someone had added a cronjob which was running after every 5 minute that was killing all php processes. ie */5 * * * * pkill php .

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘