How to setup cron job for clear cache and re-indexing in Magento. i don't know how to set the cron for re-index. but i saw some where every day cron runs defaultly in magento. still i am facing re indexing issues in my site. i need to clear cache also.On Magento website here
they said that logcleaning and reindexing is commented out in the code so in which file I can un-comment to setup cron job fo log cleaning and reindexing?
thanks,
murali.
To create the cron job, add the following to your cron file to reindex every day at 6am
0 6 * * * php -f /shell/indexer.php reindexall
Note: If you get an error telling you you’re out of memory similar to:
PHP Fatal error: Allowed memory size of 262144 bytes exhausted (tried to allocate 7680 bytes) in …/app/code/core/Mage/Index/Model/Indexer.php on line 163
Try commenting out php_value memory_limit and php_value max_execution_time in your .htaccess file.
I have tested my solution in my cPanel 11.52.2.4. So stay calm and do following:
Navigate to your magento2 admin area. And click over System > Index Management.
From the Actions drop down select Update by schedule and click on submit.
That is it from admin section. Now navigate to the cPanel area and do following-
Login to your cPanel
Under cPanel click on Cron Jobs under Advanced tab group
If you have already created a cron job, you can edit it, or create a new cron job.
Select the frequency to run the cron job, suppose Once per week (0 0 * * 0).
Write the command to re-index the data, as
php-cli /home/username/public_html/sub_folder_if_any/bin/magento indexer:reindex
Save it. As per your schedule frequency, the cron job will run.
If you want lesser frequency, but note that if you put less frequency it will consume the resource.
Note: Make sure you replace <username> with your cPanel user name and /<sub_folder_if_any> as per your magento2 installation directory. If you are not using any sub directory just ignore it
We've the same problem and fixed change Megabytes to Bytes.
instead of set memory_limit 1024M we changed to 1073741824.
Looks like an issue at server... We're hosted at Media Temple using Plesk Panel
Hope you sorted it out sooner.
Regards
Related
We have one Magento 2 project where we configured cron every min. Ideally the site has no change but still all cron jobs running too frequently.
Questions :
How Magento consider to re-run a index even there is no change.
Magento cron running synchronize or parallels way.
How to prevent run indexing if there is no change any lock or anything Magento manage ?
If your indexer is update by schedule.
then only changed data will be reindexed not all.
There is a schedule set for the crons. If you find that the frequency is too short, you can change the frequency of crons in a crontab.xml file.
You need to know the cron's name and its instance.
You can refer following link for configure cron time.
https://amasty.com/blog/configure-magento-cron-job/
I tried to deploy static content of magento 2 but php memory limit exceed error pops up every time.
Even my cron jobs are not running it giving me the same error in cron.log files.
You can use php -d memory_limit=2G in every command you run as a temporary solution to your problem but for permanent solution you must go for change in your php.ini file max_memory_limit to somewhat according to your requirement for Magento it must be minimum 765MB but you can give 2G for better functionality.
I would like to be able to set all indexes to "Update on schedule" and then have them all update automatically like Magento says they should in the background. The problem is, this doesn't happen. There is no cron job that automatically reindexes (See this related question).
So, if I have to create my own cron job, how do I do this exactly in an efficient way? I don't want to run "php shell/indexer.php reindexall". That does full rebuilds of index tables. Sure, I could do that nightly, but that means that no changes will be reflected on the frontend until the next day. That's not an acceptable solution. If I run full reindexes throughout the day, I end up with the same problem that I have right now - table locks and slowness due to reindexing while people are working in the admin.
Magento's new "partial reindexing" should fix this right?
This is my understanding of how it works:
I edit an entity that has a related index (e.g. A product).
A database trigger adds a record to related change log tables.
Some process later reads the change log tables and reindexes these specific entities
Concrete example
I update a value in "catalog_product_entity_varchar".
The database trigger "trg_catalog_product_entity_varchar_after_update" flags this product as changed by inserting a new version into "catalog_product_flat_cl" and "catalogsearch_fulltext_cl".
A partial reindex process reads these change log tables and reindexes only the products mention to "catalog_product_flat" and "catalogsearch_fulltext" respectively.
If this were the case, the reindexing process would be minimal and could be run often. Even every minute to where indexing becomes almost unnoticeable to admin users. (I say every minute, because Magento tells us this is possible)
In this release, however, the flat catalog is updated for you — either every minute, or according to your Magento cron job.
Where is this mystical partial reindex? How do I call it instead of reindexing everything?
Is there a reindexPartial()?
The enterprise_refresh_index cron job appears to run this. It runs every time the Magento cron runs. See Enterprise_Index_Model_Observer::refreshIndex().
This is not intended to run manually because of the need to establish a lock file. It is easiest just to run the cron.php file if you need a manual reindex.
I believe I just have a project specific issue with this not running.
The partial reindexing is executed through the cron job operator built into Magento. You do not need to run the actual indexer.php file. Instead, you must setup Magento's built in Cron scheduler based on the documentation.
Documentation: http://www.magentocommerce.com/wiki/groups/227/setting_up_magento_in_cron
You simply execute the cron.php file, which will in turn call the partial reindexing process.
php5-cli -f /home/USERNAME/public_html/cron.php
How it works:
A change to the an entity is made and is flagged to be reindex.
A cronjob executes the cron.php file
Magento checks to see which cron tasks it will run, and runs the partial reindexing process
The indexing process will see the changed entity and update the index tables with the new values.
I have set up my cronjob for Magento to run every two hours, that is the quickest my host can set it to. However, newsletters don't get sent until I actually go into my host's control panel and click the 'Run' button for the particular cronjob.
What did I do wrong? My cron path is set as: /bin/sh /usr/www/users/FTP_USER/cron.sh
It is because the event observers are loaded based on the context (adminhtml,frontend or in your case crontab). The newsletter sending observer is not on the crontab list so it cannot send emails.
See this article: http://www.aschroder.com/2010/01/magento-events-explained-and-a-few-gotchas-avoided/
I imagine this is highly likely to be a permissions/PATH problem of one form or other. When you manually trigger the event by clicking something in the control panel, it is probably getting ran as the Apache user (www-data or equivalent, depending on the platform). The cron will most likely be running as a different user to this.
Assuming you're referring to the core newletters cron Mage_Newsletter_Model_Observer::scheduledSend, it's unlikely there's any problem with cwd being incorrect for relative include paths. This leaves the most likely culprits a.) the cron user doesn't have execute permissions on your cron.sh, b.) the cron user doesn't have access to the mail application on the server, because it isn't include in the users PATH.
In my experience the cron.sh script hasn't been up to it. Consequently I just run the cron.php . This requires php cli being setup properly with enough RAM and sensible timeouts.
In your crontab try:
* * * * * /usr/bin/php /home/USER/public_html/cron.php >> /home/USER/public_html/var/log/cron.log 2>&1
I also keep a log file in var/log/cron.php so that I can see errors made during a cron job.
I've just moved my Magento site to a new server and I'm trying to re-index my store using the Index Management.
I check all the boxes and re-index and I get the following:
Cannot initialize the indexer process.
I've looked at resetting the file permissions using the Magento Cleanup tool. But nothing I've tried seems to work.
Has anyone ever come across this before and how did they get past this?
Many thanks
I don't have any idea why you can't do it from the Index Management, but as a temporary solution, I would advise to use indexer.php script from the cmd line:
php /var/www/magento/shell/indexer.php reindexall. You can also run it by the system cron periodically, it should do the trick for a while.
delete files from var/locks and change permission of folder to 755, it will work..if donot have any issue with Dataseb files