试图将这个问题弄清楚几个小时......
我已经获得了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中运行相同的命令,它可以完美地运行......任何想法?
答案 0 :(得分:0)
您应该在--
后面添加命令参数:
36 22 * * * php -f /home/user/public_html/shop/shell/indexer.php -- --reindexall
作为php
的手册页建议:
php [options] [ -f ] file [[--] args...]
否则php
试图将这些参数解析为自己的参数并失败。
答案 1 :(得分:0)
我能想出的最佳解决方案是......
创建一个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文件。