Problem/Motivation

The site has too many contents (the latest content node ID is 142538) and when the automated cron is run the following message is reported in the logs and this repeats several times. The sitemap is never updated after that and needs to be rebuilt manually every day!

Steps to reproduce

All the Sitemap configeration is set as neccessary but the automated cron fails to update the sitemap. When we click on Rebuild sitemap manually, the sitemap is updated successfuly.

Comments

ankithashetty created an issue.

nravens’s picture

I have the same issue. Have you found the cause and solution?

ankithashetty’s picture

Hey @nravens, sorry, I didn't find the cause of this issue.

But to make this work, I went to /admin/config/search/xmlsitemap/settings and checked Disable cron generation of sitemap files..

Then I set up crontab on my system, something like this 0 2 * * * /usr/bin/drush -r /var/www/html/drupal_test_site/ xmlsitemap:regenerate >> /home/ubuntu/drupal_test_site-cron.log 2>&1. This will execute the drush command every day at 2:00.

This seems to work for me, might as well give it a try?

Thanks!

cebab54’s picture

I have the same problem. But I think the isse is to expose the sitemap fields used to the anonymous user. It certainly overcame access to robotstxt module becoming exposed to search consoles at Bing and Google

loopy1492’s picture

Oddly, our site was also not regenerating the xml sitemap during drupal's cron. Here's the correct crons for an Acquia Next site:

Default schedueld task:
```
/usr/local/bin/cron-wrapper.sh site.environment https://yoursite.com &>> /shared/logs/default-drush-cron.log
```
xml sitemap regeneration scheduled task:
```
cd /var/www/html/${AH_SITE_NAME}/docroot && drush xmlsitemap:regenerate &>> /shared/logs/xmlsitemap.log
```

Edit: markdown when, drupal.org?

binnythomas’s picture

I am facing the same issue on the site. However it only occurs intermittently and very difficult to reproduce and ascertain the root cause.

freelock’s picture

We also see this on a site with > 50K links. Sometimes it generates 3 sitemap pages with exactly 10K links each, sometimes 2, sometimes none. When run manually from drush, it generates 6 pages, the first 5 10K links and the remainder on the 6th. But doing this today took 1 hour 24 minutes to complete...

We might try the workaround suggested -- disabling the cron generation and adding our own drush cron job... or give simple_sitemap a try.

piotr pakulski’s picture

I'm also experiencing that cron is not reliable. In my case when I unpublished some node in EN language, in meantime cron regenerated the sitemap then I unpublished the other language version of the same node, then the cron simply did not include that change into the other language sitemap. Walk-around will be setting cron drush command to rebuild the sitemap. I do not want invest more time into investigating that.

dalin’s picture

Note that you can adjust at
/admin/config/search/xmlsitemap/settings
I set it to process only 50 items at once rather than the default 100, and it now successfully completes.

dalin’s picture

Actually, that wasn't working reliably. But throwing this into a custom module seems to be working:

/**
 * Implements hook_cron().
 */
function mymodule_cron() {
  $logger = Drupal::logger('mymodule);
  $logger->info('Starting `drush xmlsitemap:rebuild` asynchronously.  It will take about 10 minutes to complete.');
  pclose(popen("drush xmlsitemap:rebuild &","r"));
}

I wonder if we should roll this into the module as an option:
* Run as a normal cron hook
* Run as an asynchronous cron hook (requires drush)
* Don't run during cron