cancel
Showing results for 
Search instead for 
Did you mean: 

Cron Jobs, SSH, reindexing

SOLVED

Cron Jobs, SSH, reindexing

Hiya,  I've installed Magento 2.2.6 and all seems to be OK.  I've added a catagory, subcategory, and a product and assigned this product to the categories, but I can't seem to find the product in the frontend, but I think it's got something to do with Re-indexing as I see the "One or more indexers are invalid. Make sure your Magento cron job is running." in the admin backend?!?!?   So I can run the command line "php bin/magento indexer:reindex", I created SSH access with the private and public keys and I log in successfully after setting up MFA with Google Authenticator:

 

Welcome to the SSH server. All activity is logged.

PHP binaries (cli):

/usr/php53/usr/bin/php

/usr/php54/usr/bin/php

/usr/php55/usr/bin/php

/usr/php56/usr/bin/php

/usr/php70/usr/bin/php

/usr/php71/usr/bin/php

/usr/php72/usr/bin/php

/usr/php73/usr/bin/php

Other binaries:

/usr/bin/lua

/usr/bin/perl

/usr/bin/python

/usr/bin/ruby

Please do not use sudo or leave your home.

Have a nice day!

* * *


When I ran the reindex command (php bin/magento indexer:reindex) I got the response:

 

 

Design Config Grid index has been rebuilt successfully in 00:00:01

PHP Fatal error:  Uncaught Error: Class 'Locale' not found in /home/sites/4a/9/95ad38fdbe/public_html/mgtrade/vendor/magento/framework/Locale/Bundle/DataBundle.php:64

Stack trace:

#0 /home/sites/4a/9/95ad38fdbe/public_html/mgtrade/vendor/magento/framework/Locale/Bundle/DataBundle.php(28): Magento\Framework\Locale\Bundle\DataBundle->cleanLocale('en_US')

#1 /home/sites/4a/9/95ad38fdbe/public_html/mgtrade/vendor/magento/framework/Setup/Lists.php(92): Magento\Framework\Locale\Bundle\DataBundle->get('en_US')

#2 /home/sites/4a/9/95ad38fdbe/public_html/mgtrade/vendor/magento/framework/Validator/Locale.php(42): Magento\Framework\Setup\Lists->getLocaleList()

#3 /home/sites/4a/9/95ad38fdbe/public_html/mgtrade/vendor/magento/module-backend/Model/Locale/Resolver.php(72): Magento\Framework\Validator\Locale->isValid(NULL)

#4 /home/sites/4a/9/95ad38fdbe/public_html/mgtrade/vendor/magento/framework/Locale/Resolver.php(65): Magento\Backend\Model\Locale\Resolver->setLocale(NULL)

#5 /home/sites/4a/9/95ad38fdbe/public_html/mgtrade/vendor/magento/ in /home/sites/4a/9/95ad38fdbe/public_html/mgtrade/vendor/magento/framework/Locale/Bundle/DataBundle.php on line 64

 

 

That's one issue I'm not sure on how to fix, but it may be that I'm running PHP5.6?!?

 

The other is when I try and create a cron job using the "crontab -e" command I get this: (as well as "crontab -l")

 

 

You (95ad38fdbe) are not allowed to use this program (crontab)

See crontab(1) for more information

 

I also tried to add a new file system owner with adduser <nameofuser> and got:

 

-bash: /usr/sbin/adduser: Permission denied

 

I thought by using Terminal SSH I would have had permission for all of this?

 

Sorry loads of stuff here, I'm very new to Magento and very VERY new to cron jobs.  I've been reading articles on various forums and sites, but I seem to be going around in circles.


Thank you.

 

 
1 ACCEPTED SOLUTION

Accepted Solutions

Re: Cron Jobs, SSH, reindexing

I've created a PHP file and added to my scheduled tasks in my control panel and it's working like a dream!

 

<?php system('<path to php> <path to root>/bin/magento indexer:reindex') ?>
<?php system('<path to php> <path to root>/bin/magento cache:status') ?>

View solution in original post

5 REPLIES 5

Re: Cron Jobs, SSH, reindexing

Also, sorry forgot to add.  When following instructions to Create the Magento crontab:

 

php bin/magento cron:install [--force]

I got the following error:

                                                          

 

[Symfony\Component\Console\Exception\RuntimeException] 
Too many arguments, expected arguments "command".       

(in a red box)

 

cron:install [-f|--force]

(in green)

 

 

Re: Cron Jobs, SSH, reindexing

As we're using a shared host, I can only run CRON jobs via the hosting control panel in the 'scheduled tasks'.  

 

I guess I need to get this CLI in a schedule as this command indexes perfectly fine.

/usr/php70/usr/bin/php bin/magento indexer:reindex

 

 

Re: Cron Jobs, SSH, reindexing

I've created a PHP file and added to my scheduled tasks in my control panel and it's working like a dream!

 

<?php system('<path to php> <path to root>/bin/magento indexer:reindex') ?>
<?php system('<path to php> <path to root>/bin/magento cache:status') ?>

Re: Cron Jobs, SSH, reindexing

did you get this error?

Stack trace:

#0 /home/egodam/domains/egodam.in/public_html/egodam/vendor/magento/framework/Crontab/CrontabManager.php(116): Magento\Framework\Crontab\CrontabManager->save('\n#~ MAGENTO STA...')
#1 /home/egodam/domains/egodam.in/public_html/egodam/vendor/magento/module-cron/Console/Command/CronInstallCommand.php(69): Magento\Framework\Crontab\CrontabManager->saveTasks(Array)

 

Re: Cron Jobs, SSH, reindexing

Hello,

 

Was you having this issue with cpanel?