Drupal 7 hook_cron - where to put

I want to add cron jobs to my Drupal 7 system, but I cannot figure out how to do this. The examples I read on Google don't explain at all where to put your code. Do you need to make a module to use my_module_cron ()?

I have a block that uses some data received from a remote location. The cron task receiving this remote data is what I need to do. Can't I add my cron job to the code for my block?

Thanks in advance.

+4
source share
2 answers

You need to create a custom module, yes. See the Module Developer's Guide for information on how to do this ... when you have the module installed, this will work:

function mymodule_cron() { // Do something } 
+10
source

Create a custom module and you need the module name.info and module.module. I this module name.module writes a hook function called hook_cron (). Using the function, you can write you cron jobs regarding the code and get the target, try it.

Syntax:

  function hook_cron() { // write your custom code here. } 
+1
source

Source: https://habr.com/ru/post/1381124/


All Articles