Harikaran K
Harikaran K

Reputation: 428

Cpanel cron jobs not working using magento?

Anyone please help me

Domain: Godaddy

Hosting: VPS server

Name Server: MNS01.DOMAINCONTROL.COM

Name Server: MNS02.DOMAINCONTROL.COM


Below are test case scenarios i did and got the result

For cron.php file gave permission to 777

Minutes Hour Day Month Weekday set to * * * * *

Test 1:

/home/domain/public_html/cron.php

Result:

/home/domain/public_html/cron.php: line 1: ?php: No such file or directory
/home/domain/public_html/cron.php: line 2: syntax error near unexpected token `dirname'
/home/domain/public_html/cron.php: line 2: `chdir(dirname(__FILE__));'

Test 2:

/usr/bin/php -q /home/domain/public_html/cron.php

Result:

Nothing display

Test 3:

php -q /home/domain/public_html/cron.php

Result:

Nothing display

Test 4:

/usr/bin/php /home/domain/public_html/cron.php

Result:

X-Powered-By: PHP/5.4.33
Content-type: text/html

Test 5:

GET https://www.domain.com/cron.php

Result:

LWP will support https URLs if the LWP::Protocol::https module
is installed.

Test 6:

GET http://www.domain.com/cron.php

Result:

Nothing display

Test 7:

I replaced above all test cron.php replaced to cron.sh and tested. Got same result.

Test 8:

/home/domain/public_html/test.php

code:

<?php echo "hello world";?>

Result:

/home/domain/public_html/cron.php: line 1: ?php: No such file or directory
hello world

Upvotes: 0

Views: 4675

Answers (4)

Harikaran K
Harikaran K

Reputation: 428

Finally i got result..

php -q /home/username/public_html/cron.php

or

php -f /home/username/public_html/cron.php

or

php-cli -f /home/username/public_html/cron.php

Reference:

http://support.hostgator.com/articles/cpanel/what-do-i-put-for-the-cron-job-command

Upvotes: 0

MikeSheen
MikeSheen

Reputation: 43

I wasn't able to get any of the above suggestions to work, but did arrive at my own solution.

I had a Magento site on a dedicated server which I moved to a Cpanel shared web host (VentraIP) - and could not get the cron working. I was seeing "PHP Notice: Undefined index: SCRIPT_FILENAME" and "PHP Notice: Undefined index: SCRIPT_NAME" errors in the error_log. I ended up modifying the cron.php (renamed to cron_for_cpanel.php) to be as follows:

chdir(dirname(__FILE__));

require 'app/bootstrap.php';
require 'app/Mage.php';

if (!Mage::isInstalled()) {
    echo "Application is not installed yet, please complete install wizard first.";
    exit;
}

Mage::app('admin')->setUseSessionInUrl(false);

umask(0);

try {    
    Mage::getConfig()->init()->loadEventObservers('crontab');
    Mage::app()->addEventArea('crontab');

    Mage::dispatchEvent('always');
    Mage::dispatchEvent('default');

} catch (Exception $e) {
    Mage::printException($e);
    exit(1);
}

The cron in Cpanel was then:

/usr/bin/php -q /home/username/public_html/cron_for_cpanel.php

Upvotes: 1

Pedro Sodr&#233;
Pedro Sodr&#233;

Reputation: 19

if your website was working, try to recompile Apache and PHP with EasyApache.

If recompile doesn't work, you can try update LWP manually (thinking in this error: LWP will support https URLs if the LWP::Protocol::https module is installed.)

wget http://cpan.uwinnipeg.ca/cpan/authors/id/G/GA/GAAS/libwww-perl-5.812.tar.gz   
tar xzf libwww-perl-5.812.tar.gz
cd libwww-perl-5.812
perl Makefile.PL
make
make test
make install

New/Best update code:

rpm -qi perl-libwww-perl
/scripts/realperlinstaller --force LWP

Upvotes: 0

Steve Robbins
Steve Robbins

Reputation: 13812

You should be using the cron.sh file over command line (not a GET), and specify the sh path

/bin/sh /home/domain/public_html/cron.sh

Upvotes: 0

Related Questions