I am using Magento 2.2.6 with a theme. www.rbhomoeoshop.com The store is using rule to offer x amount of discount on each and every product. There is no condition for discount.

after every 2 or 3 days the discount rule is removed by it self. I have to run a reindex command manually, using ssh.

One of my developer friend gave me a php file with reindex command and set a cron to run that php file twice in a day.

I am getting mail on execution of the cron file but the re-index command is not working. There is no error.

current cron setting

Requesting all to suggest a solution.

  • could you add cron-man.php code ? – Pawan Feb 15 '19 at 4:18
  • Check database table cron_schedule see if your cron status is success. This will only show magento cronjobs. You don't need to run additional cron for reindex Magento cron should reindex this automatically – Shoaib Munir Feb 15 '19 at 4:23
  • <?php $cmd = "php -dmemory_limit=5G /home/rbhom2u9/public_html/bin/magento cache:clean"; exec($cmd, $a); var_dump($a); print("<hr/>"); $cmd = "php -dmemory_limit=5G /home/rbhom2u9/public_html/bin/magento cache:flush"; exec($cmd, $b); var_dump($b); print("<hr/>"); $cmd = "php -dmemory_limit=5G /home/rbhom2u9/public_html/bin/magento indexer:reindex"; exec($cmd, $c); var_dump($c); – Niraj Nagar Feb 15 '19 at 5:26
  • print("<hr/>"); $email_from = "support@rbhomoeoshop.com"; $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); mail("xxx@gmail.com", "Cron Man", "Cron Man executed."); – Niraj Nagar Feb 15 '19 at 5:27

Magento cronjob should run index automatically, there is no need to schedule through another file..

Please recheck following

1. Check cron mode:

System -> Tools -> Index Management

Check if catalog rule indexes' modes are set on "Update on Save"

2. Cron (Scheduled Tasks)

Store -> Configuration -> Advance -> System

In Cron (Scheduled Tasks) tab check if Generate Schedules Every value should be 1.

3. Check database table cron_schedule see if your cron status is success.

4. If it wont resolve execute cron manually and check if it is working:

php /home/rbhom2u9/public_html/update/cron.php
  1. Check if update in progress flag exists in var directory if it exists, give read write permission to var directory and remove file var/.update_in_progress.flag and try to execute cron manually
| improve this answer | |
  • Update on schedule is the setting. – Niraj Nagar Feb 15 '19 at 5:28
  • settings in Store -> Configuration -> Advance -> System --- are as below. 1,4,2,10,60,4320, yes – Niraj Nagar Feb 15 '19 at 5:29
  • 1
    [2019-01-02 09:18:40] update-cron.WARNING: Update is already in progress. [] [] [2019-01-02 10:20:53] update-cron.WARNING: Update is already in progress. [] [] [2019-01-04 03:50:55] update-cron.WARNING: Update is already in progress. [] [] [2019-02-15 05:38:33] update-cron.WARNING: Update is already in progress. [] [] – Niraj Nagar Feb 15 '19 at 5:41
  • 1
    The problem is, that there are more connections to the database, than mysql allows. The reason is most likely an inappropriate config for php/mysql. (e.g. more php-fpm worker than allowed mysql connections) To allow more connections, the value for "max_connections" in the mysql configuration (Default path: /etc/my.cnf) file must be modified. – Shoaib Munir Feb 15 '19 at 5:53
  • 1
    Reference: github.com/magento/magento2/issues/11924 – Shoaib Munir Feb 15 '19 at 5:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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