Configuring cron jobs on hosteurope

Setting up a cronjob at hosteurope

This Document shows one way to set up a cronjob at hosteurope. There may be other ways, this one works.

1. Grab your FTP-Account

Edit /scripts/cron-lynx.sh

Be sure that FTP works as expected and you can connect to your installed drupal-site via an ftp-client (like cyberduck, filezilla or some other, terminal-ftp will do it, too). Connect to your drupal-site, navigate to /scripts and open file cron-lynx.sh for editing. In cyberduck just doubleclick the file, an approbiate editor should launch. Other ftp-clients will need you to download cron-lynx.sh to your desktop.

You should see something like this:

#!/bin/sh
/usr/bin/lynx -source http://example.com/cron.php > /dev/null 2>&1

The first line is for the operating-system to tell it that this file will be interpreted by shell. Just leave it. The next line is the standard-drupal suggestion for lynx-based cronjobs. Comment this line out by putting a # sign in front of it (or simply delete it) and write this:

lynx -dump http://[your-website-url]/cron.php?cron_key=[your-cron-key] > /dev/null

Solving cron problems

Various things can keep cron from doing its job on your Drupal site. If your Status report (admin/reports/status) indicates that cron hasn't run recently, try the following to diagnose and fix the problem:

Make sure cron.php is being called at all

If your Status report indicates that cron has never run, you may simply need to configure configure a cron job. If you can successfully run cron manually from your Status report screen, Admin menu, or Drush, this is almost certainly the case. If manually running cron fails, you have a deeper problem...

Understand how update.modules permission interacts with cron.php

In 6x, update.modules became part of core. By default, user 1 has permission to run update.module. To expand that permission, you need to grant the user permission to "administer site configurations." You can test this behavior by running cron.php logged out versus logged in as admin. You may find that cron.php is performing correctly even if does not update modules -- check the permissions to see if that is true.

Check for problems with cron itself

Using Perl to run cron

If you're having problems with cron using curl and wget is not allowed on your server try out the curl call from the shell on another box - you may find you get HTML delivered saying "page not found."

If this is the case you can also use Perl to perform the call to the cron script.

You need command line access to Perl and the LWP::Simple module installed. Your crontab entry then becomes:

45 * * * * perl -MLWP::Simple -e "getprint 'http://yourdomainhere/cron.php'"

Automatic multisite cron using php5

Create a new file preferably in the same directory as your drupal dir. Name it 'cronall.php' or something. Copy the following script into it. Then adjust the settings in the file, and visit the script with your webbrowser, to see if it is setup correctly.
Then create a cronjob for the cronall.php script, and you're done.


<?php
/**
* This script scans the sites directory, and uses a regular expression to extract the sitenames.
* It then uses this sitename to execute the cronjob for these sites.
* You then only have to create a cronjob for this script.
* In this way, you can create and delete sites on the fly, but all their cronjobs will be executed.
*/

/***********
* SETTINGS
**********/
//the location of the 'sites' directory relative to this script.
$sitesDir = '../drupal/sites';
/**
* A regular expression that matches the name of the directories in
* the 'sites' dir that you want to execute cronjobs for, with a
* backreference around the actual site name. (so we can exclude the
* domain part)
*
* If you don't know regular expressions you might want to brush up
* on them: http://www.regular-expressions.info/tutorial.html
*
* Alternatively, you can just copy the name of one of the directories
* in the site dir, put a backslash \ in front of all dots . and replace
* the actual name of the site with ([a-zA-Z0-9_-])
*/

Cron script for multi source, multi site setup

I've just hacked up this little script as I have multiple installations of drupal each with multiple sites that get more each day. This should figure out which sites cron should run for.

Configuring cron jobs using the cron command

Cron is a daemon that executes commands at specified intervals. These commands are called "cron jobs." Cron is available on Unix, Linux and Mac servers. Windows servers use a Scheduled Task to execute commands.

For a modest personal site, you might set up this cron job to run once a day. For a more active site you might want to run that job more often—perhaps every few hours or every hour. This regular visit will tell Drupal to perform its periodic tasks, and this will help keep your system running smoothly.

Subscribe with RSS Subscribe to RSS - crontab