• Magento Cron and Google Sitemap Auto Generate Mystery Solved

    by  • September 10, 2011 • Magento • 7 Comments

    After major testing and messing around with code we were able to figure out on some Magento installs why Google Sitemap would auto-generate and others would not.

    Turns out to be a combination of conflicts with other cron scheduling, server resources, the Cron Configuration and Google Sitemap cron configuration. Lots of variables. The solution is to get all those schedules, well . . . scheduled.

    What we discovered was that the server’s cron was firing nicely, about every 15 minutes. To clarify, the server’s cron is not set within Magento but typically within the server’s control panel like Cpanel, Plesk . . . and the settings of the server’s cron schedule are these obscure symbols of confusion – that is until you understand how cron scheduling works (check out Wikipedia for some explaination).

    Here is one example of cron scheduled to execute a command every 15 minutes.

    */15 * * * * – Some command

    The problem we were having was that other cron dependent features of Magento would show up in the cron_schedule table but not that pesky and notoriously allusive “sitemap_generate”, Magento‘s Google Sitemap cron schedule code.

    What is the “cron_schedule” table you ask? Well, it is where Magento queues all it’s cron schedule codes to be run. This is the best place to check on what is being run, what’s erroring, what’s completed and what’s pending to run next. It also includes date info for when the queued item was created, when it is scheduled to run, when it ran and when it finished. So, basically it is a great place to start troubleshooting all your cron problems.

    What we ended up doing to check and see why the “sitemap_generate” code was not showing up in the cron_schedule table was editing the configuration setting for Google Sitemap within the core_config_data table. We updated the path value “crontab/jobs/sitemap_generate/schedule/cron_expr” to a new expression you can’t create in Magento Admin > Configuration > Catalog > Google Sitemap > Generation Settings and that new wonderful expression of freedom was */5 * * * *. After the change database change make sure you Flush Cache Storage at Magento Admin > System > Cache Management or your changes will not take effect. If for some reason it still does not work you can comment out the entire <section> element in system.xml found here: app/code/core/Mage/Sitemap/etc

    So, what we told Magento to do is execute the generation of the Google Sitemap every 5-minutes. We wanted to see if it was some bug in the code. Turned out it was not a bug and low and behold the “sitemap_generate” code showed up in the cron_schedule table! It was a site for sore eyes, let me tell ya.

    So now we are tweaking our cron settings in Magento Admin > Configuration > Advanced > System > Cron (Scheduled Tasks) so that we can have Google Sitemap generate one time a day.

    I’ll post our findings when we get all the scheduling line up correctly.


    A jolly ol' chap that enjoys the everyday cliff drop, skate park, climbing crag and tree run mixed with a heavy dose of development and design of web sites, print and video production and the rush of marketing ventures.

    7 Responses to Magento Cron and Google Sitemap Auto Generate Mystery Solved

    1. September 17, 2011 at 3:57 pm

      It really is difficult to find skillful persons for this topic, you seem like you are aware of what you are posting on! Thanks a lot

      • Dan
        September 17, 2011 at 8:41 pm

        Thank you. Greatly appreciate the feedback!

    2. October 7, 2011 at 1:45 pm

      Superb posting, I absolutely await fresh news from you.

      • Dan
        October 11, 2011 at 4:19 pm

        Thanks. Glad you liked it.

    3. Gustavo
      November 1, 2011 at 11:38 am

      I not understand exatly what I make, but, is working now!

    4. September 14, 2012 at 9:50 am

      Please help in Magento! I have sitemap.xml on the root but when I try link http://www.mywebsite.co.uk/sitemap.xml I got a 404 Not Found. When I try to submit to the google webmaster tools is the same.

      • Dan
        September 20, 2012 at 2:33 pm

        Have you tried changing the location of the sitemap.xml from root to a subdirectory?

    Leave a Reply

    Your email address will not be published. Required fields are marked *