hook_cron() is not working I've created a new Drupal 7 module, which has been installed and enabled.

I have this function in the module. 

function remove_entries_cron() {
  $query = "INSERT INTO {search_dataset} (sid,type,data) VALUES (22061986, node, hello)";
  db_query($query);
}


I have cleared the cache, and ran the cron manually but the record doesn't appear in the database.

Is there a way to check if the cron hook is working?
To check if a cron hook is being invoked, you need to output something to an existing database, for example using one of the following functions:


watchdog() requires you enabled the Database logging module; otherwise, no entry will be added to the watchdog table, and admin/reports/dblog would not show new entries
variable_set() always set a value in a database table, but the value returned from variable_get() could be the value set in the settings.php file for the $conf array
The database API functions can be used, but you need to be use the database table exists; for example, use a database table installed by a module, even if it a module of yours


In the second case, don't use a Drupal variable (e.g. this_is_a_wrong_variable), for which the following code exists in settings.php.

$conf['this_is_a_wrong_variable'] = 'This value will be always returned from variable_get().'


If you do so, whatever you set with variable_set('this_is_a_wrong_variable', 'My hook is invoked: ' . time()) will not be returned from variable_get() which would return 'This value will be always returned from variable_get().', in the example I made.

As you discovered, every Drupal hook must have a name prefixed by the module short name. In fact, the code used by Drupal to invoke a specific hook used by all the modules is the following one.

  foreach (module_implements($hook) as $module) {
    $function = $module . '_' . $hook;
    if (function_exists($function)) {
      $result = call_user_func_array($function, $args);
      if (isset($result) &amp;&amp; is_array($result)) {
        $return = array_merge_recursive($return, $result);
      }
      elseif (isset($result)) {
        $return[] = $result;
      }
    }
  }


As you see the function name for the function implementating a hook is $module . '_' . $hook. For the Node module, the hook_cron() implementation would be node_cron(); for an hypothetical module_with_a_long_name module, the hook_cron() implementation would be module_with_a_long_name_cron().  

Bear in mind that, if you edit the code of an enabled module to add a new hook, you need to disable and re-enable it, or Drupal will not see you added a new hook has been added to the module, since the list of hooks implemented by a module is cached. See module_implements().

  // Fetch implementations from cache.
  if (empty($implementations)) {
    $implementations = cache_get('module_implements', 'cache_bootstrap');
    if ($implementations === FALSE) {
      $implementations = array();
    }
    else {
      $implementations = $implementations-&gt;data;
    }
  }