[英]Cron Job - Magento - Reindexall not working
一直試圖弄清楚這個數小時...
我已經有了cron設置,並且可以在預期的時候運行。
36 22 * * * php -f /home/user/public_html/shop/shell/indexer.php --reindexall
產出
Error in argument 3, char 2: no argument for option -
Usage: php [-q] [-h] [-s] [-v] [-i] [-f <file>]
php <file> [args...]
-a Run interactively
-b <address:port>|<port> Bind Path for external FASTCGI Server mode
-C Do not chdir to the script's directory
-c <path>|<file> Look for php.ini file in this directory
-n No php.ini file will be used
-d foo[=bar] Define INI entry foo with value 'bar'
-e Generate extended information for debugger/profiler
-f <file> Parse <file>. Implies `-q'
-h This help
-i PHP information
-l Syntax check only (lint)
-m Show compiled in modules
-q Quiet-mode. Suppress HTTP Header output.
-s Display colour syntax highlighted source.
-v Version number
-w Display source with stripped comments and whitespace.
-z <file> Load Zend extension <file>.
-T <count> Measure execution time of script repeated <count> times.
如果我刪除-
36 22 * * * php -f /home/user/public_html/shop/shell/indexer.php reindexall
它輸出
Usage: php -f indexer.php -- [options]
--status <indexer> Show Indexer(s) Status
--mode <indexer> Show Indexer(s) Index Mode
--mode-realtime <indexer> Set index mode type "Update on Save"
--mode-manual <indexer> Set index mode type "Manual Update"
--reindex <indexer> Reindex Data
info Show allowed indexers
reindexall Reindex Data by all indexers
help This help
<indexer> Comma separated indexer codes or value "all" for all indexers
如果我在SSH中運行相同的命令,則可以正常工作...有什么想法嗎?
您應該在--
后面添加命令參數。
36 22 * * * php -f /home/user/public_html/shop/shell/indexer.php -- --reindexall
如php
手冊頁所示:
php [options] [ -f ] file [[--] args...]
否則, php
會嘗試將這些參數解析為自己的參數,並且會失敗。
我能找出的最佳解決方案是...
創建一個PHP文件,強制Magento模型對其自身重新編制索引
//
// Initiate Magento MAGE
//
$mage_php_url = "app/Mage.php";
// Include Magento's Mage.php file.
require_once($mage_php_url);
/* @var $indexCollection Mage_Index_Model_Resource_Process_Collection */
$indexCollection = Mage::getModel('index/process')->getCollection();
foreach ($indexCollection as $index) {
/* @var $index Mage_Index_Model_Process */
$index->reindexAll();
}
echo "<h1>Re-Index Completed.</h1>";
設置cron作業后,運行此簡單的PHP文件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.