The following TaskDefinition options determine how the Scheduler handles tasks after they are completed:
resultLimit — Controls how many seconds a task is allowed to run after the task has completed. The default setting varies for different tasks. A setting of zero immediately removes tasks after completion.
resultOption — Controls what action is taken when repeated instances of a task are started. The default setting is delete, which removes extra task instances.
These default settings are designed to optimize memory by shortening the lifetime of finished Scheduler tasks. Unless there is a compelling reason to change these settings, use the defaults.
If you want to immediately delete tasks that completed successfully, but you also want to keep tasks containing errors long enough to debug, you can do the following:
Conditionally delete finished tasks by setting the resultLimit value to a time period that is sufficient for debugging issues.
Set the resultLimit to zero (or a small value) if no errors (such as WF_ACTION_ERROR is <null/>) are reported at runtime after a WorkflowServices call.