简体   繁体   English

如何查找cron超时或cron作业错误?

[英]how to find whether the cron timeout or error in cron job?

I fetch some data from the remote server and feed it into my site database .It has 900k of records(app) but the insertion of records stopped 60,180 records only. 我从远程服务器获取一些数据,并将其输入到我的站点数据库中。它有900k条记录(应用程序),但是插入记录仅停止了60180条记录。 We use mailto and an exception handler to find the bugs but no response. 我们使用mailto和异常处理程序来查找错误,但没有响应。

Can anyone offer advice on how to get the cron timeout or do we have an error in code our code? 谁能提供有关如何获得cron超时的建议,或者我们的代码在编写代码时出错?

<?php
set_time_limit(0);
ignore_user_abort();
try
{
  $ch = curl_init();
  // set URL and other appropriate options
  curl_setopt($ch, CURLOPT_URL, "http://ks329xxx.com/cronRU/update");
  curl_setopt($ch, CURLOPT_HEADER, 0);
  // grab URL and pass it to the browser
  curl_exec($ch);

  // close cURL resource, and free up system resources
  curl_close($ch);
}
catch (Exception $e) 
{
  echo 'Caught exception: ',  $e->getMessage(), "\n";
  mail('varunxxxx@xxxxx.com', 'update', $message);  
}
?>

You're not checking for the result of curl_exec() : 您没有检查curl_exec()的结果:

if (curl_exec($ch) === false) {
    throw new Exception(curl_error($ch));
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM