0
votes

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
4
It's normal for nothing to display when cron.php runs. Via command line, you just get a new command prompt, via http, all you get back is an http header and a blank page. The only way you can tell it's working because you end up with entries in the cron_schedule table. At which point, I'd use phpMyAdmin to check for entries from all the times you got those blank results and concentrate on the ones where you got error messages.Fiasco Labs
Have a look here: stackoverflow.com/questions/25177502/magento-cron-job/25183755. There are some suggestions. I found that for my provider 1and1 I had to specify the right version of php (see my answer).PedroKTFC

4 Answers

1
votes

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
0
votes

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
0
votes

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
0
votes

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