簡體   English   中英

Magento cron.php通過Cron或php調用時引發錯誤

[英]Magento cron.php throws error when called via Cron or php

我最近使用Magento托管了我的網站,設置了cron.php后,我得到以下輸出:

/home/xxx/webapps/abc/cron.php: line 1: ?php
: No such file or directory
/home/xxx/webapps/abc/cron.php: line 2: /**
: No such file or directory
/home/xxx/webapps/abc/cron.php: line 3: bin: command not found
/home/xxx/webapps/abc/cron.php: line 4: $'*\r': command not found
/home/xxx/webapps/abc/cron.php: line 5: bin: command not found
/home/xxx/webapps/abc/cron.php: line 6: $'*\r': command not found
/home/xxx/webapps/abc/cron.php: line 7: syntax error near unexpected token `('
/home/xxx/webapps/abc/cron.php: line 7: ` * This source file is subject to the Open Software License (OSL 3.0)

'

我將其托管在Webfaction上,並且似乎該錯誤僅在Webfaction上發生。 我在另一個服務上托管的其他網站(使用相同的Magento版本)運行良好。

即使我在cron.php上刪除了以下幾行,它仍然不起作用:

/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * 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.
 *
 * DISCLAIMER
 *
 * 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-2016 X.commerce, Inc. and affiliates (http://www.magento.com)
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */

我還嘗試將“ shebang”放在

#!/usr/local/bin/php

並得到以下結果:

/usr/local/bin/php^M: bad interpreter: No such file or directory

我懷疑編碼可能有問題。 誰能幫我這個 ?

編碼可能不如換行符。

不同的操作系統使用 ASCII格式的回車符和換行符的不同組合 Windows使用回車+換行(ASCII代碼0x0D + 0x)作為換行符。 Linux / Unix僅使用換行(ASCII代碼0x0A)。

當您看到^M ,通常會告訴您文本中有無法打印的字符(除非您的字面意思是Caret + M,這是不尋常的)。 您可以在此處(錨點后的第一個表,[b]列)中看到控制字符及其“插入符號”的映射: https : //en.wikipedia.org/wiki/ASCII#Control_characters

鑒於^ M是回車符,在Linux中不使用,並且在Windows中的換行之前使用,所以我首先想到的是您的文件正在Windows上進行編輯,然后推送到Linux服務器。 Linux無法解釋以Windows CRLF行結尾的shebang行 ,因此可以解釋shebang問題。

但是,PHP旨在在其解釋器中處理CRLF,因此我懷疑這是第一個問題。 您沒有確切描述文件的執行方式,因此我假設您正在遵循這些說明 如果我的假設是正確的,那么您將使用此處描述的三個cron行: http : //devdocs.magento.com/guides/v2.0/config-guide/cli/config-cli-subcommands-cron.html#create定時工作 在那種情況下,我猜想使用了錯誤的PHP版本。 我認為在WebFaction上,如果使用/usr/local/php的默認PHP版本是5.2,而Magento 2.1需要PHP 5.6。 可能是您的問題,但沒有更多細節,很難確定。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM