Logging to the SiteCron Last Run Log

time

I’ve worked with SiteCron quite a bit, but up until recently I hadn’t realised until recently that there was a field that should be used to track what happened when the Cron Job last ran, this field is the ‘Last Run Log’.

I think it’s been around since version 2.18 but I didn’t notice it and couldn’t find any examples online which showed me how to use it:

cron-job-log

 

 

 

 

 

 

 

 

I wasn’t sure how to update it but as It is a Multiline text field I figured I could just be update it like any other Sitecore field like so:

The script is pretty simple, it gets the Job Item and then finds the field and updates it. Thankfully SiteCron has some constants that can be used to help here.

Notice how I’m appending to the field to build up an historic log of each run. This is useful if you have a job that runs multiple times a day/week and need to look back at the last x runs to see what happened.
I’m logging both successful and unsuccessful runs. Obviously you can change the log message to say what you want.

Anyway I hope this is useful to others using SiteCron who want to log what the Job does when it runs.

Published by

Adam Seabridge

I am a Freelance Sitecore Developer and 7x Sitecore Technology MVP (2024 - 2018). I have been working with Sitecore since 2013. You can reach me on twitter @billyjava or comment below if you have any questions or feedback.

One thought on “Logging to the SiteCron Last Run Log”

Leave a Reply

Your email address will not be published. Required fields are marked *