繁体   English   中英

Cron Job-Magento-Reindexall不起作用

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM