Skip to content

Is this the right command to have a cron job reindex my Magento 2 site automatically 4 times an hour?

Magento 2.4.5-p1

I have a problem which I’m guessing stems from some illegal characters in some of my product fields which results in the products in categories NOT loading every once in a while. When I run reindex manually via SSH (Putty):

php bin/magento indexer:reindex

It brings the products back and shows them in categories on the front end as expected.

I haven’t had a chance to manually go through all products and check/correct the irregularities. I have setup the following cron jobs in my cPanel initially to run every hour but there must be something wrong because the site still keeps crashing at least once a day and when I waited for the tasks to run, it still didn’t fix it (even-though there was reindex in there). This makes me believe the commands are not actually getting executed. I have since changed the times from each hour every day to the following:

3,8,13,18,23,28,33,38,43,48,53,58   *   *   *   *   /opt/cpanel/ea-php74/root/usr/bin/php /home/MYSITE/public_html/cron.php > /dev/null    



*/10    *   *   *   *   /opt/cpanel/ea-php74/root/usr/bin/php /home/MYSITE/public_html/bin/magento cron:run 2>&1 | grep -v "Ran jobs by schedule" >> 
/home/MYSITE/public_html/var/log/magento.cron.log
    

10  14  *   *   *   cd /home/MYSITE/public_html %% php bin/magento setup:di:compile
    
13  14  *   *   *   cd /home/MYSITE/public_html && php bin/magento setup:static-content:deploy -f
    
3   14  *   *   *   cd /home/MYSITE/public_html && php bin/magento cache:clean

5   14  *   *   *   cd /home/MYSITE/public_html && php bin/magento cache:flush

0,17,30,45  *   *   *   *   cd /home/MYSITE/public_html && php bin/magento indexer:reindex

7   14  *   *   *   cd /home/MYSITE/public_html && php bin/magento setup:static-content:deploy -f

Do these appear to have the correct syntax?

Is there any other way to execute reindex manually? I will be traveling for a week and I won’t have access to SSH (Putty).