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

Step 5: Setting up cron

Setting up cron is an important step in the installation of the website and assists in the maintenance of the site's assets for search results, checking for updates to Drupal core and modules, and removing temporary files.

A properly configured cron job can manage a variety of tasks:

  • the Search module that indexes the website's content
  • the Aggregator module's that retrieves feeds
  • the Ping module that notifies other sites of updates
  • the System module that performs routine maintenance tasks, such as pruning of logs

What is cron?

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. The actual "cron job" is a time-triggered action that is usually (and most efficiently) performed by your website's hosting server, but can also be configured by a remote service or even from your own desktop.

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.

#!/bin/bash

SITESROOT=/var/www/sites
MYIPRANGE=41.204.221

Running cron manually

To run cron manually in Drupal 7

Go to Administration > Reports > Status report. Scroll down to "Cron maintenance tasks" and click "run cron manually" at http://example.com/admin/reports/status/run-cron

In that same section, core also provides a link with a unique cron_key to run cron from outside your site.

To run cron manually in Drupal 5 and 6

To run a cron job manually, simply visit your own site's url at http://example.com/cron.php with your web browser, and cron will run and complete in the background. You'll be left with a blank white page, which is normal. Use the browser's back button to return to the previous page and continue where you left off. It doesn't matter how long you wait while you're seeing the blank white page, and returning to the previous page at any time won't stop the cron process from running.

Core provides a convenience link for running cron manually too. Look at the Status page's link: /admin/logs/status/run-cron?destination=admin%2Flogs%2Fstatus. You can paste that into your own site's address bar any time you want to run a cron.

In addition, if you have the update_status.module installed, and you should since it's simply glorious, you'll be presented with a custom link on your admin/logs/updates page.

Pages

Subscribe with RSS Subscribe to RSS - scheduled tasks