Monitor Maintenance Tasks

To monitor last start and last completed times for maintenance tasks in SCCM, run the below SQL queries. At the bottom of this page is an example of running a maintenance task on demand.

select * from SQLTaskStatus Order by LastStartTime desc

To calculate the duration of each task, the above query can me modified as such:

select *,
floor(DATEDIFF(ss,laststarttime,lastcompletiontime)/3600) as Hours,
floor(DATEDIFF(ss,laststarttime,lastcompletiontime)/60)- floor(DATEDIFF(ss,laststarttime,lastcompletiontime)/3600)*60 as Minutes,
floor(DATEDIFF(ss,laststarttime,lastcompletiontime))- floor(DATEDIFF(ss,laststarttime,lastcompletiontime)/60)*60 as Seconds
from SQLTaskStatus Order by LastStartTime desc

The output when calculating durations will look as follows:

maintenance1

Running Maintenance Tasks on demand

If you need to run a maintenance task on demand, follow these steps:

Example: If you need to run the ‘Delete Aged Replication Data’, modify the ‘RunNow’ column and set to 1. The task will be added to the queue to run at the earliest possibility.

update STS set RunNow=1  from SQLTaskStatus STS where TaskName = 'Delete Aged Replication Data'