I
I
ila109652017-04-06 15:13:17
PHP
ila10965, 2017-04-06 15:13:17

Server kills PHP script on timeout. What to do?

They asked me to write a rather complicated "script" in PHP, and I'm not a backend guy.
So the man is a gag. Where there is a gap, there is my baldness.
Well, I washed it down, it should, it just has to run on the URL and the infection takes a long time to run (2-3-4 hours), but rarely.
However, the server kills its execution after 10-12 minutes, there is some kind of timeout, and changing it is impossible.
At first, everything was even worse, but I forced the server to print me a report on how things were going there, overflowing the buffer (it just worked out that way) and it spits out a line to me in the browser.
But it still dies after 10-12 minutes.
And the script, in short, crawls into all sorts of dark places with its requests, downloads all kinds of dregs via api, sorts it furiously in all poses, and then furiously sends what happened to another place, along the way saves information about what was done (this was not necessary, but since everything tsuka fell every 12 minutes, then I had to look for ways to save progress so that I didn’t start from scratch each time).
I don't boom boom at all, please help!
If possible, with a simple example where some kind of garbage can run for a very long time and not die.
Thank you!
And yes, there are all sorts of words, the meanings of which I don’t know, but they are shorter in this project of the century:
php 5.6, apache, nginx
And yes, this is not a lack of memory, if so.
Everything is ok with memory, this is a timeout.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
D
Dmitry Serpokrylenko, 2017-04-06
@ila10965

Such - "long-running" scripts must be run by cron.

V
Viktor Taran, 2017-04-06
@shambler81

increase timeout

D
dmitriy, 2017-04-06
@dmitriylanets

1. break the functionality into smaller tasks,
2. use the task/queue manager to perform each task separately.

U
Uno, 2017-04-08
@Noizefan

I recommend not to implement such massive php scripts in the future, because his idea is absolutely not in creepy demons.
Serious people use the right languages ​​for the right tasks.
Take a look at concise Python and the like - learns quickly, especially after puff (no, I'm talking about php).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question