cancel
Showing results for 
Search instead for 
Did you mean: 

How sitemap cronjob works in Magento 2?

How sitemap cronjob works in Magento 2?

Hello the community!


I got some questions about cronjob system in Magento 2.

 

I'm currently working on a Magento 2.1.2 version and I'm facing an issue about Sitemap cronjob generation. It's simple Sitemap aren't update with cronjob.

 

1. Job format

Looking on the job declaration, I noticed that the job doesn't have schedule:

<job name="sitemap_generate" instance="Magento\Sitemap\Model\Observer" method="scheduledGenerateSitemaps" />

 

So, is it supposed to work anyway? What is the default schedule used?

 

2. Sitemap Start Time option

Under Store > Configuration > Catalog > XML Sitemap > Generation Settings, I can choose the Start Time.

I can see the cron expression on Core_config_data table under "crontab/default/jobs/sitemap_generate/schedule/cron_expr" path, but can't find any use in Magento source files. 

 

There is something similar on the Sitemap Observer Model (app/code/magento/Sitemap/Model/Observer.php):

 

/**
* Cronjob expression configuration
*/
const XML_PATH_CRON_EXPR = 'crontab/default/jobs/generate_sitemaps/schedule/cron_expr';

It's "generate_sitemaps" instead of "sitemap_generate" but again the XML_PATH_CRON_EXPR constant is never used.

 

Is this feature really working?

 

To test, I added schedule to the job in crontab.xml and the job start to work...

 

I am missing something?

 

Thank you,

 

ps: Yes I generated my sitemaps under Marketing > Site Map and added cron:run on the server crontab.

 

1 REPLY

Re: How sitemap cronjob works in Magento 2?

 

Hey, I got the same issue, also I have ran manually the cron job task via cli using below command but didn't work.


bin/magento cron:run --group generate_sitemaps
bin/magento cron:run --group sitemap_generate

 

I tought the issue was related with my server time, I can't get it work properly.