My apologies if this has been asked before (I've searched but found nothing relevant yet). I'm trying to use hook_cron and the batch API to update about 7000 small nodes on a nightly basis, via a csv file. I've got my module working fine with page and menu callbacks but when I try to kick off the job using cron I get "Cron run failed." and if I run it again I get "Attempting to re-run cron while it is already running." Is it even possible to use the two together? If so, what am I missing? Thanks!

Comments

John Carbone’s picture

OK, I figured this out. In case anyone else has the same problem, I was missing a "finished" function and call. That missing call was also causing the batch to keep restarting, even when called from a normal page. Once I got it in, it solved both problems.

xjm’s picture

I was having this same problem. Thanks for posting the fix.

winnie80’s picture

any chance that you can share your custom module, or perhaps good tutorial or step by step on how to achieve this cron + batch api?
thank you in advance