Magento Cron Job cron.sh vs. cron.php

Interesting fact for us majority of the times we perform a health check in the scope of our Magento Technical Support plans that most of Mageto merchants use cron.php to run the cron. Well, it is good that there is a cron running for Magento at all. However, cron.php is the actual working script that needs to launched within the wrapper cron.sh to avoid overlapping of cron jobs on the server that eventually lead to exceptions and a bad morning for a merchant who just realized something went wrong.

Lets take a look at the cron.sh wrapper:
#!/bin/sh
# 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
No secret, all it does is checks for the running process of cron.php and runs the new one only and only if the old one has finished its execution.

The correct way of setting up Magento cronjob would be:
*/5 * * * * /bin/sh /path_to_magento/cron.sh
Cheers!

We Love Our Customers

    Team of US based Certified Magento Engineers will work directly with you (no middle-men) to make sure MagePhobia provides best quality technical services. Some of our Magento Engineers are ex-Magento employees who built Magento for several years and know Magento inside-out.
    MagePhobia provides affordable
Magento Services with one of the best quality on the market.
    Our US based Technical Support is provided exclusively by our Certified Magento Developers and System Administrators, and is available 24/7 via ticketing, chat, and phone.
    MagePhobia offers short and long-term contracts as well as 'per job' basis contracts. We refund in case of unsatisfactory results which, we believe, will not occur ever.

We are all-in for customer satisfaction!