- Steve McNiven
Sitefinity has the ability to create cronjobs that run on timers in the background, they call them ScheduledTasks. They handle things like publishing\unpublishing on specific dates, but you can hook into the system yourself to run tasks as well! 🔥
If you want to see what your site is doing, since there’s no UI for it, have a peek inside the sf_scheduled_tasks table.
So here’s a sample of what I have going on a Live site. The concept is a mail system that runs on a timer to look for new messages, then flushes a queue. All that code though is stripped out though, but it would exist here.
This expands on the Official Documentation by making sure there are no other instances of this task in the database, we REALLY didn’t want to have multiple instances of this class executing at the same time. Maybe it’s overkill, but that’s better than multiple tasks 😊
So you need to register in inside your Global.asax, and the code can obviously just live wherever since it’s compiled. Depending on the frequency of it’s execution you can dial back the logging I have to not bloat out your log folder. In the official code on the site I use a Sitefinity Configuration element so I can turn it on or off without restarting the site.