On cron runs, I want to edit every node of a certain content type. I think this is implemented through hook_cron() but I can't find any documentation about this hook. How can I edit every node of a certain content type on cron runs?

I need this because I update content on nodes based on another website. I want the content to be updated regularly. I need something similar to feeds but the data source is just HTML not xml.

  • Editing all nodes during a cron run is a recipe for disaster, and I would strongly advice you against it. If you are trying to edit all nodes on Drupal only once, then you would be far better off with hook_update() Jan 5, 2012 at 6:54
  • 2
    Why exactly do you need to edit every nodes of a content type, and what do you need to edit?
    – apaderno
    Jan 5, 2012 at 8:48
  • I updated the quesiton Jan 6, 2012 at 4:52
  • Possibly dupe of drupal.stackexchange.com/questions/45539/…
    – giorgio79
    Apr 6, 2016 at 4:00

2 Answers 2


You would need to implement various hooks.

hook_cron: It will get called on every cron run. Here you could load every node in the system using node_load(), edit whatever properties of the node you need to edit, and then save each edited node using node_save().

However, note that both loading and saving a node is an expensive process, and if you have a site with many nodes, your site would become very slow, unstable, or even unusable on every cron run (which can sometimes happen as often as every 15-30 minutes). In other words, I would be very cautious with whatever you are trying to accomplish.


Here's the documentation for hook_cron.

Can you be a little more specific about what you want to do? My first thought is to recommend Views Bulk Operations, but that's more for one-time updates rather than every-cron-run updates.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.