I have a really slow-running action (30-45 seconds) that loops over each user in my DB and syncs the data with some off-site database. I want this to happen once or twice daily, so I have a WP-Cron job setup to trigger the action.
My problem is that the action isn't essential for rendering the page, so ideally it's something that would run in the background instead of blocking the page rendering.
Is there any built-in system in WordPress that'll do this kind of thing?
One really hacky solution I thought of was to trigger the action via AJAX and just let it run in the background as the user visits the page. It doesn't seem like a good option, so I wanted to hear if you guys have any inputs or thoughts about a cleaner way to achieve this.