Friday, May 13, 2016

Simple Drupal CRON

Here is the snippet for simple cron using custom module. We are just calling a function while executing the cron (menucallback).

 * Implements hook_cronapi().
function modulename_cronapi($op, $function=NULL) {
    switch ($op) {
        case 'list':
            return array('modulename_cronname' => t('CRON Human Readable Name'));
        case 'rule':
            return '*/20 * * * *';
        case 'execute':
            return 'menucallback';

After this refresh the module cache and go to admin/config/system/cron to view this newly created cron.

No comments:

Post a Comment