Create a task that allows you to schedule it for a future time. This can be, but is not limited to, a Quick Delivery, Package Delivery, Gather Inventory or Run Script task.
Add a schedule for a future time. Do not use the "Run now" option.
Notice that this creates a scheduled task in the Windows Task Scheduler named "NS.Run <task name>".
Then notice that these tasks remain in the Task Scheduler after they have run, even though the schedule is not set to repeat.
There is no purging mechanism in place to remove these expired scheduled tasks from the Task Scheduler. The number of scheduled tasks in the Task Scheduler will continue to grow every time a schedule is added to a task. This can eventually cause some performance issues with the Task Scheduler.
The work-around is to manually delete the old, expired, schedules from each task. The following SQL will delete task schedules that are over 20 days old and were set to run only once.
insert into ItemToDelete
select vir.Guid , getdate()
from ItemReference ir
left join vItem vic on vic.Guid = ir.ChildItemGuid
left join vItem vir on vir.Guid = ir.ParentItemGuid
where ir.Hint = 'taskschedulehint'
and CAST(vir.state as XML).value('(/item//scheduling//schedule/@start)','Varchar(30)') < dateadd(DAY,-20,getdate())
and CAST(vir.state as XML).value('(/item//scheduling//schedule/trigger/@type)','Varchar(max)') = 'Once'
and vic.Attributes = 0
Our Task Server team has submitted an Enhancement Request to create a mechanism to automatically purge old, expired, scheduled tasks from the Windows Task Scheduler that were created when scheduling a task . We do not have an estimate of when this feature will be incorporated into the product.