View Full Version : Cron Job To Run cron.php in Drupal
chloe
05-14-2009, 08:53 AM
Hello,
I looked on the previous threads but couldn't find anything on this. I'm new to setting up cron jobs. I need to run the cron.php page on my Drupal website once per hour. Does anyone know of a script that would do this?
Thanks in advance for your help.
JamesYap
06-01-2009, 01:43 PM
The instructions is available here
http://drupal.org/cron
deardive
07-08-2009, 03:41 AM
Steps:
In the Advanced area of the cPanel click on Cron jobs.
Choose your experience level Standard.
Create a new entry by filling out the last area that should be empty.
In Command to run type /ramdisk/bin/php5 -q /home/youraccountname/public_html/yoursite.com/cron.php (if that doesn't work try /ramdisk/bin/php5 /home/youraccountname/public_html/yoursite.com/cron.php).
Set how often cron should run. I normally run it every hour, but I make sure they crons don't run contemporary (a five minute difference should be okay).
Email address where cron output should be sent, leave as it is. It should mention your account name.
Click Save Crontab at the bottom.
This is the one SimpleScripts puts for you in the cron jobs:
/ramdisk/bin/php5 -f /cron.php >> /dev/null 2>&1
tsorelle
11-11-2009, 04:07 AM
BlueHost support recommends something like:
/ramdisk/bin/php5 -q /home/your_user_name_here/public_html/cron.php
There are a few problems with this:
1. Need to make the drupal site root the current directory.
2. Need to pick up settings from the local custom php.ini file
3. Need to surpress the spurious session warning issued by Cron.php. This causes an email to be issued for every run, because there is always output.
I resolved these issues by creating a script named drupaljobs.php that does a little setup before including the Cron.php script:
-----------
<?php
// settings from may local php.ini file:
ini_set('include_path','.:/usr/lib/php:/usr/local/lib/php:/home/your_user_name_here/php');
ini_set('memory_limit','96M');
// change to root directory of drupal site
chdir('/home/your_user_name_here/public_html');
// turn off error reporting
error_reporting(0);
// run cron.php
include("cron.php");
---------------------
I call this from cron with something like:
/ramdisk/bin/php5 -q /home/your_use_name_here/public_html/drupaljobs.php
The -q switch, contrary to some posts on Drupal.org, is needed to surpress header output. Since all output is surpressed no e-mail message will be sent so you need to monitor the cron job using the Drupal admin reports.
Alternatively, you could surpress the email by blanking the email field on the "Standard Cron Manager" screen. However, this will disable e-mail notification for all cron jobs. Some other scripts that I run depend on e-mail notification.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.