We recently added a new gist to our github account - a Magento 1 command line database syncing tool. Most store owners will find the need to have at least a staging site for their store, and probably a development site as well. While it's easy enough to get the staging environment mirroring production in terms of configuration, and the fileset handled by version control, syncing the database contents is less straightforward - but none the less desirable.
In an environment where you want to mirror production as closely as possible both in terms of configuration and data, having database contents lagging far behind production isn't ideal. Take for instance a situation where you find a bug that is apparent on production but not in any other environment. In my experience 99% of the time you eventually find issues like this to be down to differences in admin configuration, and therefore the database. So it's important to have your stores staging environment properly synced to production to give yourself the best chance of finding any bugs before code is deployed to your production environment.
That's exactly what our syncing tool does - it requires n98-magerun and takes an already exported dump of your production database, imports it to your staging site and updates the install specific contents such as base url, cookie domain and secure front/backend settings.
You can find the script here with full usage instructions underneath. I hope you find it useful!
Showing posts with label troubleshoot. Show all posts
Showing posts with label troubleshoot. Show all posts
27 January 2016
18 April 2012
Magento cron jobs not running
Sometimes you can find the cron jobs for your Magento store just aren't running, or are running intermittently even though everything has been setup correctly and there is apparently no reason for it.
Surprisingly you might find the problem is actually down to a simple caching issue with a one line code fix. Magento caches it's cron schedule and reads this cached content on subsequent runs of cron rather than recreating the schedule each time to determine which jobs it should execute. The problem is sometimes jobs just don't get cached despite them being configured correctly so when the time comes for them to execute nothing actually happens.
It's worth noting that the cron schedule is cached even if all caching is disabled in admin, and the only way to clear the cached schedule through admin is to Flush Cache Storage under System->Cache Management. Unfortunately this doesn't then cause the jobs to be correctly cached the next time cron is run.
So the fix is to simply disable the caching of the cron schedule, and don't worry, benchmarks with caching disabled shows this to have no negative impact on site performance.
Copy:
Surprisingly you might find the problem is actually down to a simple caching issue with a one line code fix. Magento caches it's cron schedule and reads this cached content on subsequent runs of cron rather than recreating the schedule each time to determine which jobs it should execute. The problem is sometimes jobs just don't get cached despite them being configured correctly so when the time comes for them to execute nothing actually happens.
It's worth noting that the cron schedule is cached even if all caching is disabled in admin, and the only way to clear the cached schedule through admin is to Flush Cache Storage under System->Cache Management. Unfortunately this doesn't then cause the jobs to be correctly cached the next time cron is run.
So the fix is to simply disable the caching of the cron schedule, and don't worry, benchmarks with caching disabled shows this to have no negative impact on site performance.
Copy:
app/code/core/Mage/Cron/Model/Observer.phpto:
app/code/local/Mage/Cron/Model/Observer.phpif it's not already there. Open the copied file and find the following line inside the generate() method:
Mage::app()->saveCache(time(), self::CACHE_KEY_LAST_SCHEDULE_GENERATE_AT, array('crontab'), null);This is the line that initiates caching of the cron schedule, so just comment it out:
//Mage::app()->saveCache(time(), self::CACHE_KEY_LAST_SCHEDULE_GENERATE_AT, array('crontab'), null);Save the changes and Flush Cache Storage to clear any currently cached cron jobs and your store should now always execute properly configured cron jobs.
Subscribe to:
Posts (Atom)