[support] Setting up cron job for user role updates

Neil: esl-lounge.com neil at esl-lounge.com
Fri Mar 9 14:40:13 UTC 2007


Victor and Greg, 

Thanks for your help.

Just for your information, I am setting up a non-ESL site on Drupal, so this isn't for the site you saw Victor. 

My host has a cron job section of the control panel, so that doesn't seem as if it will be too difficult.

I am now looking into getting my first ever crontab set up just so I can see it working, then I'll worry about setting up the script itself to update user roles. I have never set up a cron job before so I am taking baby steps, where to put the script, where to set up the schedule. There seems to be a lack of "Cron Jobs for Idiots" type tutorials on the web, but I'll keep lookiing.

That DB Cron module looks very useful Greg, although it's not available in 5.1.

I'll keep looking into this and thank you both once again.

Neil
  ----- Original Message ----- 
  From: Victor Kane 
  To: support at drupal.org 
  Sent: Friday, March 09, 2007 12:29 PM
  Subject: Re: [support] Setting up cron job for user role updates


  It's always been my wish to run an ESL site!
  I taught ESL for many years until getting into IT in the late eighties. My whole purpose of getting into IT was to seek help for my teaching academy, but once in the new realm, I was caught up entirely by it :) 

  So I certainly would like to help you.

  Running cron is part of the realm of the operating system, outside of Drupal.

  Your hosting company will allow you to edit cron via a panel; they may force you to edit cron directly through text you enter, or they may have some kind of interface to make life easy for you. 

  If that is not the case, then you will have to fill in something like the following:

  # m h  dom mon dow   command
  0   3   *   *   *   wget -O - -q http://mentor/drupal/cron.php 

  Please see the excellent documentation on the Drupal site at http://drupal.org/cron which explains all and gives alternatives to wget. There are also instructions for certain hosting companies like Dreamhost, etc. Check out the comments at the bottom of the page for some illuminating explanations. 

  Drupal has a poormanscron module, but I would recommend running cron directly.

  Once you have done this, you can now enable the core search module which will index your site, and you will be able to supplement the pearl script you are currently using with Drupal's powerful built-in search facilities. 

  You should do this first, at least for testing purposes, to make sure you have cron running.

  For your second step, you need to write a module which implements 
  The file cron.php invoked by cron calls http://api.drupal.org/api/5/function/drupal_cron_run and this  some housekeeping and then invokes all module implementations of hook_cron().

  The search module, for example, does the following:

  /**
   * Implementation of hook_cron().
   *
   * Fires hook_update_index() in all modules and cleans up dirty words (see 
   * search_dirty).
   */
  function search_cron() {
    // We register a shutdown function to ensure that search_total is always up
    // to date.
    register_shutdown_function('search_update_totals');

    // Update word index
    foreach (module_list() as $module) {
      module_invoke($module, 'update_index');
    }
  }

  You would need to write a module which, in its modulename_cron() function effectively iterates over the users and carries out the changes you propose.

  Cheers, 

  Victor Kane
  http://awebfactory.com.ar


  On 3/9/07, Neil: esl-lounge.com <neil at esl-lounge.com> wrote:
    Here is my wish: to run a cron job a few times a day to update all Authenticated Users to Full Members once they have posted five comments/forum posts.

    My plan is to have all comments posted by Authenticated Users moderated but move users up to the Full Members role I will create to cut down on moderation work. How would I go about doing this? Is there any documentation on drupal.org about setting up cron jobs? There don't seem to be any modules to allow this. Userpoints exists but isn't free. A simple cron job seems to be the easiest solution all round. Has anyone else put something like this in place?

    Neil

    --
    [ Drupal support list | http://lists.drupal.org/ ]





------------------------------------------------------------------------------


  -- 
  [ Drupal support list | http://lists.drupal.org/ ]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20070309/0f55510c/attachment.htm 


More information about the support mailing list