Execute long and heavy processes

I have developed a plugin to my WordPress website which has a sync (I’ll call it a “sync” because it does a lot of stuff to sync my database with another one) method that can take up to 20 minutes to finish. It’s not doable to associate that sync event to a button in my admin area because the post request wouldn’t wait 20 minutes, resulting in timeout.

The first thing I thought was to create a scheduled job. I have a scheduled job here for another sync task that takes 9 minutes and it runs good! But for this specific new sync event, I’d have to set up the parameters manually… so, it can be done with a scheduled job, but would require some workarounds, like a job to read from the database and when it finds the parameters it runs… but I don’t like this idea.

Well, is there any mechanism like threads or something that I can trigger in a button click, which would send back a response (so I could even close my web browser) and in the server side it would start this sync event?

Read more here: Execute long and heavy processes

Leave a Reply

Your email address will not be published. Required fields are marked *