WP_Cron script not updating all posts in loop

The wp-cron process runs as a web request. PHP processes run from the web typically have a limit to their run time, like 60 seconds or so. Processes run as a command line process (like from a real cron) have no such limit.

So the problem here is that the script takes too long to run and gets killed. There is no fix for this, wp-cron is not intended to do long-running custom scripts.

And if you keep hitting facebook’s Graph API 60 times an hour, they’ll eventually block you. Scale it back, you should only get this information once a day, at most.

Better yet, write the script so that it only updates info for those posts when they are actually accessed in the last day or so, and just uses the cached info the rest of the time.