I am presently running an Apache server (2.2) on my small local machine (Home windows) which I am using to operate some PHP scripts to consider proper care of some tiresome work. Among the scripts involves a lot of moving, resizing, and download / uploading files to a different server. I'd greatly such as the script to operate constantly to ensure that I do not have to baby the script by beginning up again each time it occasions out.

set_time_limit() ignore_user_abort(1)

Both of them are occur my script, but after about 30mins for an hour the script stops and that i obtain the 504 Gateway Time-out message during my browser. Can there be something I missing in Apache or PHP to avoid the timeout? Or must i be running the script an alternative way?

Or must i be running the script an alternative way?

Certainly. You need to run your script from command line (CLI)

basically should implement something similar to i can you 2 different scripts:

  • A. process_controller.php
  • B. process.php

The workflow ought to be:

  1. the consumer call the script A using a browser
  2. the script A start the script B using a system() or professional() and pass into it a "process token" via command line.
  3. the script B write the execution status right into a shared space: personal files named because the token, a database table. generally something that may be read also through the script A using the token as reference
  4. the script A consists of an AJAX call, in polling, that request towards the script A the status from the process for any given token

Ajax polling:

 var $myToken;  
 function ajaxPolling()
   $.get('process_controller.php?action=getStatus&token='+$myToken, function(data) {

 setInterval("ajaxPolling()",60*1000); //Every minute

you will find some factors concerning the communication between your 2 processes, based on the number of cases of the script B you'd have the ability to run in parallel

  1. Only one: you do not need a random/unique token
  2. One per user: session_start(); $token = session_id();
  3. Several per user: session_start() $token = session_id().microtime()

use phps system() to call a spend script which begins somethingOrhistory task

If you want to run it form your browser, You need to make certain that there's not php execution limit within the php.ini file, but additionally that there's not limit occur mod_php (or no matter what you're using) under apache.