Incipit: I have never used sh before.
My server is using linux RedHat and every time I run cron.sh, the server sends me an email with:

shop/cron.sh: line 45: expr: command not found
shop/cron.sh: line 46: ps: command not found

Cron string: /bin/sh /home/mn0198/public_html/shop/cron.sh

I have read that it may be a problem of portability, but I don't even know where I should start.

# Magento
# This source file is subject to the Open Software License (OSL 3.0)
# that is bundled with this package in the file LICENSE.txt.
# It is also available through the world-wide-web at this URL:
# http://opensource.org/licenses/osl-3.0.php
# If you did not receive a copy of the license and are unable to
# obtain it through the world-wide-web, please send an email
# to license@magento.com so we can send you a copy immediately.
# Do not edit or add to this file if you wish to upgrade Magento to newer
# versions in the future. If you wish to customize Magento for your
# needs please refer to http://www.magento.com for more information.
# @category    Mage
# @package     Mage
# @copyright  Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
# @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
if [ ! "$1" = "" ] ; then

if [ ! "$2" = "" ] ; then
    MODE=" $2"

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
# the following lines are 45 and 46
if [ "$INSTALLDIR" != "" -a "`expr index $CRONSCRIPT /`" != "1" ];then
    if ! ps auxwww | grep "$INSTALLDIR$CRONSCRIPT$MODE" | grep -v grep 1>/dev/null 2>/dev/null ; then
    if  ! ps auxwww | grep "$CRONSCRIPT$MODE" | grep -v grep | grep -v cron.sh 1>/dev/null 2>/dev/null ; then

EDIT - Command test

I have run these through putty ssh(I don't know if it's correct):

command -v expr >/dev/null 2>&1 || { echo >&2 "not installed.";}
hash expr >/dev/null 2>&1 || { echo >&2 "not installed.";}
type expr >/dev/null 2>&1 || { echo >&2 "not installed.";}

command -v ps >/dev/null 2>&1 || { echo >&2 "not installed.";}
hash ps >/dev/null 2>&1 || { echo >&2 "not installed.";}
type ps >/dev/null 2>&1 || { echo >&2 "not installed.";}

All of them return not installed

  • What is the hosting operating system? expr and ps are standard linux CLI utilities. computerhope.com/unix/uexpr.htm and computerhope.com/unix/ups.htm – B00MER Nov 8 '15 at 20:17
  • Try with /bin/bash /home/mn0198/public_html/shop/cron.sh – Imaginaerum Nov 8 '15 at 20:35
  • @Imaginaerum Already tried with no success... – Razorphyn Nov 8 '15 at 22:17
  • 1
    @B00MER Well, they answered me that shared hosting plans have a lighter OS which don't include those two commands(???)...so yeah, it's pointless to run the sh if ps is not executed, beside the correct execution of the hearthbeat function of AOE_scheduler module...is it possible to use let instead of expr and pgrep instead of ps? – Razorphyn Nov 9 '15 at 20:59
  • 1
    Use php -f cron.php instead in your cron if your host doesn't support, ps or expr. – B00MER Nov 9 '15 at 21:03

Use php -f cron.php instead in your cron if your host doesn't support, ps or expr.


Just using php -f cron.php doesn't do what cron.sh does.

cron.sh tries to prevent multiple instances of cron.php while php -f cron.php just starts another cron while the first might still run.

that could lead to dead locks!

Edit: Perhaps that's a work around (Mittwald provides that solution)?! It utilizes a lock file instead:

# Compatible versions:,,,,,,
ABSOLUTE_PATH=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)/$(basename "${BASH_SOURCE[0]}")

function cleanup() {
    for cpid in $(jobs -p); do kill $cpid; done
    rm -f $lockfile

trap cleanup 1 2 3 6 9 15

if [ ! -f $lockfile ];then
    echo $$ > $lockfile
    exit 0

if [ -n "$1" ] ; then

for i in default always; do
        $PHP_BIN $INSTALLDIR/$CRONSCRIPT -m$i 1>/dev/null 2>&1 &
rm -f $lockfile

exit 0


  • 1
    I know, unfortunately the linux comands necessary to accomplish this task aren't supported by my host... – Razorphyn Nov 16 '15 at 23:06
  • I edited my answer with a possible solution – Rico Neitzel Nov 24 '15 at 21:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.