title: PHP script stops suddenly without any error
body: <p>I have a PHP script that downloads files with direct link from a remote server that I own. Sometimes large files (~500-600 MB) and sometimes small files (~50-100 MB). </p>
  
  <p>Some code from the script:</p>
  
  <pre><code>$links[0]="file_1";
  $links[0]="file_2";
  $links[0]="file_3";
  
  for($i=0;$i&lt;count($links);$i++){
  
      $file_link=download_file($links[$i]); //this function downloads the file with curl and returns the path to the downloaded file in local server
      echo "Download complete";
      rename($file_link,"some other_path/..."); //this moves the downloaded file to some other location
      echo "Downloaded file moved";
      echo "Download complete";
  
  }
  </code></pre>
  
  <p>My problem is if I download large file and run the script from web browser, it takes upto 5-10 minutes to complete and the script echos upto "Download complete" then it dies completely. I always find that the file that was being downloaded before the script dies is 100% downloaded.</p>
  
  <p>On the other hand if I download small files like 50-100MB from web browser or run the script from command shell this problem does not occur at all and the script completes fully.</p>
  
  <p>I am using my own VPS for this and do not have any time limit in the server. There is no fatal error or memory overload problem. </p>
  
  <p>I also used <code>ssh2_sftp</code> to copy files from the remote server. But same problem when I run from web browser. It always downloads the file, executes the next line and then dies! Very strange!</p>
  
  <p>What should I do to get over this problem?</p>