Hundreds of old tasks show in the Windows Task Scheduler that were never cleaned up
search cancel

Hundreds of old tasks show in the Windows Task Scheduler that were never cleaned up

book

Article ID: 172577

calendar_today

Updated On:

Products

IT Management Suite

Issue/Introduction

The Windows Task Scheduler had hundreds of old tasks that only ran one time showing in scheduler UI.  The tasks had names similar to the following:

NS.Run Install Adobe Reader 11.x on Schedule.{42b01c88-6dc6-4a5f-9aee-9636715a15d0}

NS.Run Update HFS Development to 1.334 on Schedule.{8E0FD42E-D54D-4A4F-AF60-8DA89E8395C7}

NS.Run Install Hash Checker on Schedule.{4928FA21-C424-4223-8DF2-1C57B5C00184}

NS.Run Install Crixos 1.3 on Schedule.{DCEAE03B-DA71-46D5-9982-616F281F2DD2}

The number of tasks cause the Windows Task Scheduler to load very slowly or even occasionally fail to load.

Environment

Management Platform 8.1 RU7 and prior

Cause

Some tasks were never cleaned up from the database when the Task Cleanup routine was ran. Others were cleaned out of the database but, due to unknown failures, they were never removed from the Task Scheduler.

Resolution

Perform the following steps.

  1. Attached to this article are two SQL scripts
  2. View Run-once tasks older than N days.sql   { Run this query against the Symantec_CMDB database to see all tasks older than N' days. The default value is 30. Change this if desired }
  3. Delete run-once tasks older than N days.sql  { This script will insert all items that fall into the established date range to be deleted }    NOTE:  As with any scripts that externally modify database contents make sure a recent backup exists.
  4. After running the SQL in  "Delete run-once tasks older than N days.sql" Run following scheduled tasks

NS.Quarter-Hour.{5834ae07-1160-4037-8a25-67aebf6a254e}

NS.Weekly.{ab7141ed-e03a-48e5-9051-a71b5912b7f2}


After refreshing the Windows Task Scheduler UI, any tasks that still show up are orphaned and must be manually deleted. Once they are manually deleted they will not come back.

 

Note: Code has been optimized to minimize this type of scenarios on 8.5 release and later. 

A way to reduce the number of obsolete or one-time schedules is by running ‘Clean up Task Schedules’ (which is available since 8.1.RU2):

  1. Go to Settings>All Settings>Notification Server> Task Settings>Clean Up Task Schedules. Add a schedule to it or run it manually as needed.

The Clean up Task Schedules task lets you disable or delete the schedules that have no occurrence in the future.

 

 

Attachments

View Run-once tasks older than N days.sql get_app
Delete run-once tasks older than N days.sql get_app