PHP を使用してバックグラウンドで実行されるジョブを作成する方法について、多くの調査を行いました。
 <?php
   ignore_user_abort(true); // run script in background 
   set_time_limit(0); // run script forever 
   // get the size of the output
   ob_start();
   include_once '';//many includes
   //$contentLength = ob_get_length();
   // these headers tell the browser to close the connection
   // once all content has been transmitted
   //header("Content-Length: $contentLength");
   header('Connection: close');
  // flush all output
  ob_end_flush();
  ob_flush();
  flush();
  // close current session
  if (session_id()) session_write_close();
 //lot of code, fetch query from DB with millions records and do calculations
  ?>
header("Content-Length: $contentLength"); を使用する場合 スクリプトは何も返しません。コメントすると、制限を使用して数千の結果が得られます。何百万ものすべてを取得したい場合、サーバーはわずか 3 ~ 4 分後に応答を停止します
膨大な統計レポートを取得する必要があるだけで、ユーザーに最大実行時間に達したというメッセージを表示させたくありません。制限時間が不明なので、時間実行制限を上げたくありません。最大で 1 時間かかる場合があります。バックグラウンドで実行する必要があります。