There is a script that takes data from the database and generates an xml file. Cycle processing takes several minutes (up to 10), about 200,000 lines are written to the file. And the code below stops running. I cause mail (), and the letter does not come. If you take less data so that the cycle can run faster, then everything works. The time to execute the script is 3600 seconds. What prevents the code from working further?
- 3perhaps the script needs to be run not from a web server, but directly, in the console (or cron). The code can no longer be executed, as the script has spent all the available memory allocated for it. - KoVadim
- How do you run the script (CLI, embedded PHP server, web server)? If a web server, which one? Also specify what parameter you set for 3600 seconds? There are limitations to both PHP and the web server. - 5f0f5
- I launch cron, apache web server. PHP settings max_execution_time 3600, memory_limit 1024M - sheldon
- oneTry this option to view httpd.apache.org/docs/2.4/mod/core.html#timeout - 5f0f5
- Measured memory_get_usage, it turned out almost 200MB - sheldon
|
1 answer
200,000 lines
This is children's volume for PHP. Well, of course, it is advisable to record a record - for example, 1k lines (1k accumulated => recorded => 1k accumulated => recorded => ... => recorded residuals) in order to measure the hard disk and spend RAM - this is 30 seconds on average gland.
Cycle processing takes several minutes (up to 10)
10 minutes is certainly not normal for 200k lines per file. And probably with such a runtime, your script falls off on timeout. To not fall off - write, for example:
ini_set("max_execution_time", 3600/*1 час*/);
But better, of course, first optimize the code.
|