Cronjobs without wget/lynx or curl

Some of you might have trouble getting lynx or wget to work. This may be the case if "localhost" is not permitted.
Then wget, lynx or curl won't work on the local machine. If you are not willing to depend on others to perform cronjobs and you dislike poormans cron, try this script.
touch ~/scripts/cron-php.sh
chmod 700 ~/scripts/cron-php.sh
vi ~/scripts/cron-php.sh

#!/bin/bash
#
# Simple cron script for those who cannot
# use wget, lynx or curl because the host
# closed the localhost loop.
#
# Usage:
# - put this file in the ~/scripts dir
# - add a cronjob pointing to this script
#
# Copyright OCS - 2006
# This script is provided under the GPL.
#
# v 0.1 original release
#

#############################
# CONFIGURATION OPTIONS
#############################

# Complete local path
#
# Set the complete local path
# to where the cron.php file
# is (ie the root path)
# Default is /var/www/html/
root_path=/var/www/html/

# Complete php path
#
# Set the complete path
# to the php parser if
# different from standard
parse=/usr/bin/php

##############################
# END OF CONFIGURATION OPTIONS
##############################

cd $root_path

if [ -e "cron.php" ]
then
  $parse cron.php
   if [ "$?" -ne "0" ]
    then
     echo "cron.php not parsed."
   else
     echo "cron.php has succesfully been parsed."
   fi
else
  echo "cron.php not found."
  exit
fi

exit

and then the crontab itself:
crontab -e
* * * * * ~/scripts/cron-php.sh > /dev/null 2>&1

where ~ is the directory where your drupal install is (the script defaults to /var/www/html/ but your professional hosting company will probably use /home/your.domain.tld/www

 
 

Drupal is a registered trademark of Dries Buytaert.