I am generating a site map page that will contain whole site structure in a tree form, An XML file will be used to store the structure and I want to update that XML file every hour, Is there any thing in Tridion to execute job in schedule?
I think you refer to a Scheduled Publishing task. It is possible do accomplish it using CME or the API. You can get some details here Publish / Republishing - Login is required.
If what you want is a Timer, then I would recommend to create an application or service that will use the API to publish when the timer period is elapsed.
Using a scheduled process running an application/powershell that contacts the core service is the easiest way to to have your sitemap updated regularly, but there are other possibilities that allow you to have your sitemap always up to date. However maybe a bit more complex.
This is an approach that worked for me in the past:
- create a TBB that publishes an xml binary, every time a page is published, with the information about your page. More information on how to accomplish it on this article. Note that you don't need the storage extension part explained on the article, only publishing the with your required data.
- Have a page in your fronted that will gather all this XML's and assemble the Sitemap on page request
- Probably you will also want to have a caching strategy for your sitemap
Tridion does not have a timer or task scheduler built in.
You can use Windows's Task Scheduler or your own custom service to run a task every hour. You could for example publish a sitemap page by using the Core Service. The Core Service on the Tridion Content Manager is a web service which alllows you to do virtually everything you do in the Content Manager Explorer.
In case you would generate a site map on the CD side you have a scheduled task which uses the CD API.
UPDATE: You can run a powershell script like this one from the Windows Task Scheduler. Just have a task executing your
powershell -file "C:\publish-your-page.ps1".
As mentioned already, SDL Tridion does not have an inbuilt timer, so you have two options basically:
Take the scheduling part outside of the CMS, and use any of the suggestions given on the other answers.
Use the Scheduled Publish actions and make the Page schedule itself each time.
For #2 that means you are not scheduling it at a set time, but just from the first time it was published it would be published again an hour later.
Now you could accomplish this either via a TBB or via an Event Handler (an Event Handler would be my preferred solution). Things to look out for is the occasional republish of the item, so in the Event Handler (or TBB) code you have to check if the Page isn't already scheduled for publish, else you end up that it will be scheduled twice an hour or more eventually.
Although most of the time we generate the sitemap directly from the CMS by publishing a page, there are lots of tools that generate the sitemap directly in the delivery area. A list of available sitemap generators can be found in for instance in:
Some of those have the option of:
--> Schedule the generation of the Site Map:
In that case there is no need of do anything else in the CMS, is just install and configure the generator in the delivery server
--> Kick off the generation/regeneration of the Site Map programmatic:
Using this technique brings the advantage that the Site Map is generated just in time when a command is executed. When you publish a page from the CMS you can use a deployer extension that triggers the generation of the Site Map. (Be very careful with this option as if you do massive publishing you will be kicking off the generation multiple times and could cause major performance problems)
Better you can use a deployer extension based on a rule that when you publish a certain component named "Site Map" for instance kicks off the generation of the Site Map. The "Site Map" component will generate nothing, is just used as a condition for the deployer to kick off the process. In this case the business user decides when the Site Map will be regenerated with a minimum publishing performance
With this answer I just wanted to add another perspective for handle the Site Map generation using specific tools that are designed and built for that purpose, not suggesting is the best option (You are adding more load in the delivery), but could be applicable for some customers that were using those before or have the requirement of use that in the project.
How about only using Tridion for this? You could have an event system that gets executed when you publish the sitemap xml page (or dcp).
That event system will schedule the same page (or dcp) for publishing in 1 hour from the time the first publishing took place. I would save the next publishing time in the page (or dcp) app data to avoid publishing/and scheduling more times than desired. The next time the page (or dcp) gets published, the event system will kick in again and re-schedule in on hour from "now", and so on and on and on...
This should work.
Note, if you want to have the ability to stop this behaviour you could set a metadata field in the page (or dcp) to control de frequency (manually, every hour, every day, etc...)
Some basic VB code to make a page re-schedule itself for publishing, in this case, every week but I'm sure you can adjust to suit:
'schedule the file to republish again the following week If RenderMode = "Publish" Then vNewPubDate = DateAdd("d",7,now()) vNewDateString = DatePart("d",vNewPubDate) & "," & DatePart("m",vNewPubDate) & "," & DatePart("yyyy",vNewPubDate) & " " & DatePart("h",vNewPubDate) & ":" & DatePart("n",vNewPubDate) vNewPubDate =CDate(vNewDateString) strPublishResult = Page.Publish (publicationTarget.Id, false, false, true,vNewPubDate) End If