How to automatically delete old Gateway's agent tasks

Version 1

    Details

    If we have a relevant number of daily Remote Scans, the number of record in the SystemTask table can grow rapidly and the performance retrieving the Agent Tasks status can be affected. This procedure shows how to delete the old tasks.


    Resolution

    1.- Create a Saved Search for the Agent Task object (Automation Tools >> Saved Search), using the expression (-30, note the minus, is the days back that we want to delete):

    $(AddDays(-30, CurrentDate()))




    Test the results with the preview and ensure that is showing what you expect.

    2.- Add a new Delete Quick Action to the object SystemTask#Agent (Automation Tools >> Actions)



    3.- Using the same workflow that is used for the daily "Remote Scan", the one called "Agentless Scan Run Daily", add a "Run For Search" block:






    This block will delete the tasks found in the Saved Search.