I tried the instructions under Magento 2 Reindexing - One or more indexers are invalid. Make sure your Magento cron job is running

but am still unable to reindex. I ssh'd into my webserver and tried running the command that was suggested from the root, php bin/magento indexer:reindex but it didn't work, so I tried going to the directory "blahblah.com"/shop/bin$ magento indexer:reindex

-bash: magento: command not found (I have a /shop directory where my files are installed)

and I tried magento indexer:status (and some others but am not able to run the commands, keep getting command not found)

I also opened up the file manager, found the magento file, opened it up and searched for indexer but am not finding it either.

Can someone help me to understand how I can reindex the status under the Index Management of my magento site? Thanks.enter image description here

1 Answer 1


You either run the command as:

php magento indexer:reindex

Or you can make the magento script executable:

chmod +x magento

After making the script excutable you can run the script as:

./magento indexer:reindex

Your magento file should look like the following:

#!/usr/bin/env php
 * Copyright © 2013-2017 Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.

if (PHP_SAPI !== 'cli') {
    echo 'bin/magento must be run as a CLI application';

try {
    require __DIR__ . '/../app/bootstrap.php';
} catch (\Exception $e) {
    echo 'Autoload error: ' . $e->getMessage();
try {
    $handler = new \Magento\Framework\App\ErrorHandler();
    set_error_handler([$handler, 'handler']);
    $application = new Magento\Framework\Console\Cli('Magento CLI');
} catch (\Exception $e) {
    while ($e) {
        echo $e->getMessage();
        echo $e->getTraceAsString();
        echo "\n\n";
        $e = $e->getPrevious();
  • I changed directory to the bin directory and issued the first command you suggested, php magento indexer:reindex but I received the following reply: Parse error: syntax error, unexpected '[', expecting ')' then tried the second suggestion, chmod +x magento which I believe it took that command and then issued the next command from the same directory ./magento indexer:reindex but received the same error as above.. Not really sure why it's not working thanks for trying.. Commented Feb 11, 2017 at 0:56
  • It sounds like when you opened the Magento file in your file manager you accidentally replaced a ) with a [ or deleted something. Are you able to upload your magento file? This new error would only occur if there was an error inside the file Commented Feb 11, 2017 at 1:10
  • @SteveBellinger first try to run php bin/magento setup:di:compile command and check what error and which file error it gives ? also check your log file Commented Feb 11, 2017 at 8:58
  • Thanks again for the help! @Andrew, it might be a problem with the script I originally ran which was on a hosted server- maybe the files I need aren't uploaded? Commented Feb 11, 2017 at 14:25
  • Thanks again for the help! @Manthan Dave, I tried running the command you suggested, but I walked the path trying to execute the command and here's the results: sbellinger@web18:~$ php bin/magento setup:di:compile Could not open input file: bin/magento sbellinger@web18:~$ cd www sbellinger@web18:~/www$ php bin/magento setup:di:compile Could not open input file: bin/magento sbellinger@web18:~/www$ cd anything.com sbellinger@web18:~/www/anything.com$ php bin/magento setup:di:compile Could not open input file: bin/magento Commented Feb 11, 2017 at 14:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.