0

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?

Jonathan Thurft
  • 129
  • 1
  • 6
  • `fastcgi_read_timeout` is the interval between [two successive read operations](http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_read_timeout) so if the response is fed progressively then the timer will reset after each read. – plasmid87 Nov 15 '13 at 14:53
  • Then how can i increase the executiong time of my PHP script? – Jonathan Thurft Nov 15 '13 at 14:59
  • 1
    You can use [max_execution_time](http://www.php.net/manual/en/info.configuration.php#ini.max-execution-time) in php.ini (or the pool settings if using PHP-FPM) or alternatively try plugging [`set_time_limit()`](http://php.net/manual/en/function.set-time-limit.php) at the beginning of the script / in the bootstrap. – plasmid87 Nov 15 '13 at 15:01
  • I;ve done what you adviced and I get a timeout now – Jonathan Thurft Nov 15 '13 at 15:18

1 Answers1

2

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?

devicenull
  • 5,622
  • 1
  • 26
  • 31