Answer the question
In order to leave comments, you need to log in
php script execution time by cron?
PHP cron script makes curl requests.
The script should process 30 addresses at a time, but in case of a long wait for a response from some of them (for example, 5 seconds), it will not have time to process all 30 in a minute. And in a minute, cron will launch another copy of the script with the next batch of 30 pieces.
How to solve such a situation so that the script does not stand idle on the one hand, but also to avoid the accumulation of running scripts on the other?
Answer the question
In order to leave comments, you need to log in
run in separate processes, if you have them going straight without stopping every minute, then it will work in parallel. But processes will accumulate. So in the end, it will most likely be clogged with processes if it does not have time to work out.
I ’ll throw in a couple more options:
1) run the script in an eternal loop, and once a minute check that it is alive.
In an eternal loop, pull 30 addresses per minute, if we meet, then we sleep, if not, then we continue to plow.
2) Run not 1 script, but several. Or run 1 script that will spawn multiple children. Thus, with the help of parallelism, we achieve an increase in the allowable response time. Those. if we run 30 descendants, then each site will have a little less than a minute to respond.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question