Thanks in advance for any assistance.
I am trying to set up cron jobs for magento.
Crontab -e was empty so I pasted the following.
# All the comment lines will start with '#' character.
# in the beginning of the file set environment variables to be used in executed tasks:
# ENV_VAR="value"
# the following line will send output for executed tasks to specified email:
MAILTO=me@domain.com
# declare running tasks in the following pattern:
# <minute> <hour> <day-of-month> <month> <day-of-week> <command>
# this example will run /var/www/public_html/cron.php every 15 minutes:
15 * * * * /var/www/public_html/cron.php
I then changed cron.php to 775 and get emailed the following;
/var/www/public_html/: line 1: ?php: No such file or directory
/var/www/public_html/: line 2: /backup: is a directory
/var/www/public_html/: line 3: 091214db.sql: command not found
/var/www/public_html/: line 4: 091214db.sql: command not found
/var/www/public_html/: line 5: 091214db.sql: command not found
/var/www/public_html/: line 6: 091214db.sql: command not found
/var/www/public_html/: line 7: syntax error near unexpected token `('
/var/www/public_html/: line 7: ` * This source file is subject to the Open Software License (OSL 3.0)'
After making the changes suggested
15 * * * * /usr/bin/php /var/www/public_html/cron.php
I now get the following email report
# location of the php binary
if [ ! "$1" = "" ] ; then
CRONSCRIPT=$1
else
CRONSCRIPT=cron.php
fi
PHP_BIN=`which php`
# absolute path to magento installation
INSTALLDIR=`echo $0 | sed 's/cron\.sh//g'`
# prepend the intallation path if not given an absolute path
if [ "$INSTALLDIR" != "" -a "`expr index $CRONSCRIPT /`" != "1" ];then
if ! ps auxwww | grep "$INSTALLDIR""$CRONSCRIPT" | grep -v grep 1>/dev/null 2>/dev/null ; then
$PHP_BIN "$INSTALLDIR""$CRONSCRIPT" &
fi
else
if ! ps auxwww | grep " $CRONSCRIPT" | grep -v grep | grep -v cron.sh 1>/dev/null 2>/dev/null ; then
$PHP_BIN $CRONSCRIPT &
fi
fi
Best Answer
The system doesn't know what language the file is, so it's having trouble executing it.
First you need to find where your PHP executable is. To do this use the
which
command:In my case the executable is located at
/usr/bin/php
so my crontab would look likeHowever, it's recommended that you use the
cron.sh
that's provided. It has some additional checks so that you don't have multiple process running. You should also have the cron run every minute or job might be missed. Because of Magento's unique cron system, this doesn't necessarily mean it's doing a lot of work, it's just checking the schedule to see if anything should be done at the moment. Try changing your crontab to