using wp_insert_post in a cron
-
Hi all,
I’m trying to run a cron that grabs an XML feed and creates posts with it. First it loops through the XML data and creates an array item for each new post in the feed.
After it’s gathered all those, it loops through the array and uses wp_insert_post() to add each one.
The problem is that this inevitably causes memory errors, or the mysql server to stop responding, or the cron script to otherwise die.
I’m watching the memory usage of the script, and it never gets above 64 megs. I have 256 allocated to PHP. I’m guessing this means the memory used by the wp_insert_post function is not included in this total.
I’ve tried to sleep() the cron for various amounts of time, but that doesn’t work.
Is there a way to wait until wp_insert_post has completed and continue the cron script then? I’m assuming it returns the post id right away, and is not done at that time.
Thanks.
- The topic ‘using wp_insert_post in a cron’ is closed to new replies.