how to properly maintain the sitemap.xml automatically?

Hi,

if my domain is domain.com,
I put my main site html pages under / public_html /,
and I'm setting up a blog at / public_html / blog /.

for my main site, sometimes,
I can manually update or download new pages.

and my blog,
I can write a new message every day.

I think to merge them into a sitemap.xml and send them to the search engine.
I find the article https://stackoverflow.com/questions/…e-sitemap-file,
I may need a sitemap.xml to merge the two sitemap files as follows:


http://domain.com/sitemap1.xml
2012


http://domain.com/blog/sitemap2.xml
2016-10-11

but you have to tag it ,
I want to ask if a script or method can automatically update and update them in the main site map?
or is not important?