I'm making module for a PHP ecommerce system. This system database have a 2000 products. I need to update all products(some values) in a one day. I dont want to update all products one time.
I try update every period 100 products when the visitor open some page (module is hooked init - header). Here i want to give time limit. If this 100 product don't update in 20 seconds make break and write last updated product id to database.
How can I do this? How this function know 20 seconds later break?
You can set time limit for the whole PHP script. So you can move out this function to separate script, set time limit there and run it as sub-process.
I recommend using Symfony Process component (can be used without Symfony):
http://symfony.com/doc/current/components/process.html
Using it you can even set time limit from your main process:
http://symfony.com/doc/current/components/process.html#process-timeout
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With