首页 文章

Cpanel cron的工作不使用magento?

提问于
浏览
0

Anyone please help me

领域:Godaddy

主机:VPS服务器

名称服务器:MNS01.DOMAINCONTROL.COM

名称服务器:MNS02.DOMAINCONTROL.COM


下面是我做的测试用例场景,并得到了结果

对于cron.php文件授予777权限

分钟小时日月平日设置为* * * * *

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:

我上面替换了所有测试cron.php替换为cron.sh并进行了测试 . 得到相同的结果 .

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 回答

  • 0

    我无法获得上述任何建议,但确实达到了我自己的解决方案 .

    我在专用服务器上有一个Magento站点,我移动到Cpanel共享Web主机(VentraIP) - 并且无法使cron工作 . 我在error_log中看到“PHP Notice:Undefined index:SCRIPT_FILENAME”和“PHP Notice:Undefined index:SCRIPT_NAME”错误 . 我最后修改了cron.php(重命名为cron_for_cpanel.php)如下:

    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);
    }
    

    然后Cpanel的cron是:

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

    您应该在命令行上使用 cron.sh 文件(而不是 GET ),并指定 sh 路径

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

    如果您的网站正常运行,请尝试使用EasyApache重新编译Apache和PHP .

    如果重新编译不起作用,您可以尝试手动更新LWP(考虑此错误:如果安装了LWP :: Protocol :: https模块,LWP将支持https URL . )

    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
    

    新/最新更新代码:

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

    最后我得到了结果..

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

    要么

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

    要么

    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

相关问题