run a cron task without obstructing page load?

Cron tasks don’t directly affect page load besides the 0.01s timeout (of course, they do affect server load, so they can impact page load indirectly).

My hunch is that your PHP config is the issue. The cron tasks run like any other web request, and they’re subject to PHP’s max_execution_time INI setting. If this is set to, say, 90 seconds, then the request will die and your files won’t sync. You can test this by setting sleep to a lower number than your max_execution_time, and see if it finishes.

If that is the case, you can try adding:

ini_set( 'max_execution_time', 0 );

to the top of your push_to_dropbox() function. It’s not a great solution, because it won’t work on every host, but it’s a start.

Leave a Comment