php - WP Cron job timeout issues

admin2025-01-07  4

I have to run a php function for around 10 minutes. Now I am sheduling the job as a wp-cron-job. But it is getting timed out after 30seconds which is the maximum execution time for php. How to get rid of this timeout issue?

I have to run a php function for around 10 minutes. Now I am sheduling the job as a wp-cron-job. But it is getting timed out after 30seconds which is the maximum execution time for php. How to get rid of this timeout issue?

Share Improve this question asked Aug 24, 2017 at 7:51 StanlyStanly 1111 silver badge5 bronze badges
Add a comment  | 

3 Answers 3

Reset to default 0

In my opinion function that works 10min is not a best idea. Can You maybe refactor Your function or simply try to build batch processing?

My favorite article about that: https://pippinsplugins.com/batch-processing-for-big-data/

30 seconds should be enough for a script in the web, but that's generally speaking.

Running your cron as php-cli will have no timeout limit, you can read more about this here

You can also increase the timeout in any php script, as discussed here - https://stackoverflow.com/questions/3829403/how-to-increase-the-execution-timeout-in-php already.

Here is also ready-made class for you to extend and batch process elegantly - https://github.com/gdarko/wp-batch-processing

I used it to run a big batch process on customers, and it's working great.

https://github.com/gdarko/wp-batch-processing

Here is an article about it

https://wptutspro.com/batch-processing-as-background-tasks/

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736261369a736.html

最新回复(0)