Drupal: .htaccess Access Deny
August 21, 2014 – 7:59 am | No Comment

In this article I will tell how to forbid access to certain resources for some clients. The instructions will include descriptions of different directives.

Read the full story »
CSS Templates

Contain reviews and news about CSS Templates.

Freebies

Contain freebies such as icons, graphics, headers and images for your websites.

Fun Stuff

Contains other fun stuff for entertainment or interesting site showcase.

How-To

Contain technical elaborations on some specific workarounds or common tweak.

Joomla Templates

Contains reviews and news about Joomla templates.

Home » How-To

Drupal: How to Run Cron

Submitted by on July 5, 2010 – 7:32 amNo Comment

This article would tell you how to set cron launching.

Drupal performs the following tasks using cron: indexing content for search, sending emails to subscribers, and other functions – modules can create regular tasks.

The tasks are run calling cron.php which is located in the site root. Therefore it is necessary to include calling cron.php in crontab. Period will depends on site traffic (from 30 minutes to 1.5-2 hrs).

Solutions
  • Manually.
  • From OS server.
  • Through hosting control panel.
  • Using additional Drupal modules.
  • Using exterior services.
  • Calling cron.php from your site but from other hosting crontab is available at.

Manually

example.com/cron.php
(A blank page will open. In the case of successful performing, you will see a message in logs)

Drupal 6: admin/reports/status/run-cron
“Status report” page will open (admin/reports/status) with a message about executing this command.

Drupal 5: admin/logs/status/run-cron
“Status report” page will open (admin/reports/status) with a message about executing this command.

From OS server

Unix

It is necessary to create .crontab file with home folder and insert a line with time and name of the script.

Windows

Run cron.php on Windows

Through hosting control panel

Alternatives of cron.php launching commands

  • Through lynx or wget
  • Tthrough /usr/local/bin/php

First of all you should get know if there is a command and path to it:
which curl
which lynx
which wget

Through lynx or wget

You can easy call cron.php through lynx or wget.
Ready shell-script which can help you in this is located in scripts/cron-lynx.sh. You should just correct host name (but do not specify localhost, specify it as you site is available from the web).
Script file should be executable at least for its owner.

Example (run cron.php every hour):

0 * * * * /usr/bin/wget -O – -q http://www.yoursite.com/cron.php
0 * * * * /usr/bin/lynx -source http://www.yoursite.com/cron.php > /dev/null 2>&1
before you insert these commands to crontab, please check if the program (wget or lynx) is in /usr/bin. To check  wget path, run whereis wget – you will see the list of file containing ‘wget’.

Many hostings run cron.php every hour, on 38 minute:

38 * * * * wget -O – -q <a href="http://www.example.com/cron.php<br />
38" title="http://www.example.com/cron.php<br />
38">http://www.example.com/cron.php<br />
38</a> * * * * lynx -source <a href="http://www.example.com/cron.php" title="http://www.example.com/cron.php">http://www.example.com/cron.php</a> > /dev/null 2>&1

How you can run cron. php every day at 1.00 pm and 1.00 am?

0 1,13 * * * wget -O – -q http://example.com/cron.php

Using of additional wget utility without parameters (default) means: number of loading attempts 20, and duration of every attempt is 900 secs (15 mins) !!! It is a huge time…
"wget -O – " command means that you will run wget utility the only time.

curl:t is

curl –silent –compressed http://example.com/cron.php

With command: /usr/local/bin/php /home/example.com/cron.php

In this case you should include files to cron.php by relative path (not absolute path). Here is how cron. php should looks like:

<?php
// $Id: cron.php,v 1.36 2006/08/09 07:42:55 dries Exp $
/**
* @file
* Handles incoming requests to fire off regularly-scheduled tasks (cron jobs).
*/
$_SERVER[‘HTTP_HOST’] = ‘example.com';
$_SERVER[‘REMOTE_ADDR’] = ‘127.0.0.1’;
$_SERVER[‘REQUEST_METHOD’] = ‘GET';
chdir(‘/home/example.com/public_html’);
include_once ‘./includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
flashvideo_cron();
/*
$users = db_query(‘SELECT * FROM {users}’);
while($user = db_fetch_array($users)) {
echo $user[‘name’] . ‘\n';
}
echo ‘all';
*/

Using additional Drupal modules

If crontab is unavailable on the hosting, you can use poormanscron module. Drupal loads scheduler’s tasks when visitors apply to pages.

Poormanscron allows compare date of the previous cron launching with the current date. If the dofference is more than specified time period, it will run cron.

With the help of exterior services

There are a special websites which allows setting of cron launches on your site:

Leave a comment!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.