I've an script that can run for about 15 min as it is a large data migration tool.

I have the problem that either if i set fastcgi_read_timeout 9900; it never times out or if i set it to less then it times out before my script finished running.

EDIT: I have taken away the fastcgi_read_timeout 9900; from nginx.conf and setted max_execution_time = 1300; in php.ini and I get a 504 Gateway Time-out now instead of looping forever.

How can I properly set that the page should be live until the script finishes executing?

  • fastcgi_read_timeout is the interval between two successive read operations so if the response is fed progressively then the timer will reset after each read.
    – plasmid87
    Commented Nov 15, 2013 at 14:53
  • Then how can i increase the executiong time of my PHP script? Commented Nov 15, 2013 at 14:59
  • 1
    You can use max_execution_time in php.ini (or the pool settings if using PHP-FPM) or alternatively try plugging set_time_limit() at the beginning of the script / in the bootstrap.
    – plasmid87
    Commented Nov 15, 2013 at 15:01
  • I;ve done what you adviced and I get a timeout now Commented Nov 15, 2013 at 15:18

1 Answer 1


Why do you want to run this in the foreground? While it's possible to hack at the config files long enough for you to get this behavior, it's a very fragile configuration. Is this something that's actually outputting useful information to the user as it goes? If not, this is almost certainly suited to a background task, rather then trying to run it in one request.

Even if this is outputting to the user, have you considered running it as a background task, and piping output to the user via some asynchronous method?

  • 1
    How would i run it on the background? Commented Nov 18, 2013 at 9:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .