Automate Sitecore Tasks with Wget
There are many blog posts out there about automating and scheduling Sitecore tasks. This post covers a scenario that I’ve used several times and just wanted to share. As John West mentions in All About Sitecore Scheduling Agents and Tasks, tasks defined in Sitecore and configured agents may not run on a site if the ASP.NET worker process has shut down due to inactivity to the site. This is often the case during off hours when you’d probably want to perform administrative tasks.
The scenario I often have is to rebuild the Lucene search indexes at off hours, usually around 3am, when the worker process can very well be shutdown due to inactivity. The process is simple: install Wget and configure a Windows scheduled task to call Wget to request a secret page on the site.
- Download the Windows version of Wget and install it on the server.
- Create a new Windows Scheduled Task in the Control Panel.
- Navigate to the Wget program for the task to run.
- Once you create the task, right-click it and select Properties.
- Modify the path of the task to include the
--spiderparameter and the URL to your page to run. Below is a sample line for a task path.
"C:\Program Files\wget-1.11.4-1-bin\bin\wget.exe" --spider http://mysite.com/obfuscated-folder/special-task.aspx
This is just one of many ways to automate running something and have it happen at a specific time of the day. Here are some pros and cons I can think of for this approach:
- Guaranteed to run at a specific time since it doesn’t rely on ticks in Sitecore
- Simple to setup and won’t require a config change and therefore won’t recycle an existing app
- Since a secret page is exposed via a public URL, you can manually run the code by hitting the page
- Isolated from the Sitecore app, and thus possibly forgotten if migrating a server
- Requires a specific page on the site to be requested, meaning a page with secret code would be exposed publicly (this can easily be fixed via permissions)
Got anything to say? Go ahead and leave a comment!
- Using the DataSource Field with Sitecore Sublayouts
- Tame Your Sitecore Treelists
- Write to a Custom Sitecore Log with log4net
- Sitecore Upgrade Strategy
- Rendering Fully Qualified Sitecore URLs
- Sitecore Admin Pages Explained
- Managing CSS in the Sitecore Media Library
- Use Any() Instead of Count() To See if an IEnumerable Has Any Objects
- Sitecore Front-End Development Best Practices
- Scaling Sitecore Presentation Component Data Sources
- Performance tuning your Sitecore installation | Agile and ALM: Software development today on A Going Live Checklist for Sitecore Websites
- Imran Saleem on Sitecore Avanced Database Crawler Occasionally Provides Null Results
- Ty Cahill on Sitecore Front-End Development Best Practices
- Sitecore Managed Sites as Virtual Folders | Fire Breaks Ice on Sitecore Item and Field Names
- Krimos on Using the DataSource Field with Sitecore Sublayouts
- Aboo Bolaky
- Alex Shyba
- Anders Dreyer
- Brian Pedersen
- Christopher Wojciech
- Coffee => Coder => Code
- Dev Sitecored²
- Everything Web
- Image0.com blog
- John West
- Learn Sitecore
- Let's do Sitecore
- Mark van Aalst
- Matthew Kenny
- Molten Core
- Project Lifecycle
- Sean Kearney
- Sebastian Patten
- Sitecore Australia
- Sitecore Blog
- Sitecore Climber
- Sitecore Development
- Sitecore Gadgets
- The Client View
- The Sitecore Experience
- Web Content Management and Delivery