Creating a Scheduled Task to Delete DNN Log Files Automatically


The DNN debugging creates log files automatically, which can be useful to troubleshoot different issues. However, log files can grow in size quickly and take a lot of disk space. This article aims to demonstrate how to create a scheduled task in Windows to delete the old DNN log files automatically. 




Server administrator credentials 




  1. Log in to the site server as an administrator. 
  2. Launch the Task Scheduler.
    1. In Windows, click Start.
    2. Type Task Scheduler.
    3. Press Enter.
  3. Right-click on the Task Scheduler Library and select New folder.
  4. Enter a name for the new folder and click OK.
  5. Right-click on the newly created folder and click Create Task.

  6. In the Name field, enter a name for the task.
  7. Enable the Run whether user is logged on or not option.
  8. Go to the Triggers tab and click New Trigger.
  9. From the Begin the task drop-down menu, select On a schedule.
  10. Under the Settings section, select the frequency to run the task.
  11. Click OK.
  12. Go to the Actions tab and click New.

    The default action is to Start a program. If it is not already selected, make sure to select it from the Action drop-down menu.
  13. Enter ForFiles into the Program/script text box.

    ForFiles is a computer software utility for Microsoft Windows, which selects files and runs a command on them.
  14. In the Add arguments field, specify the argument that you want to pass to the ForFiles script. Depending on your specific needs, modify the argument below by replacing the [path to log files] and the [days] placeholders: 

    /p "[path to log files]" /s /d -[days] /c "cmd /c del @file"
    The sample argument that is presented below removes files older than 90 days from the C:\DBA\SQLTrace folder.
    /p "C:\DBA\SQLTrace" /s /d -90 /c "cmd /c del @file"
  15. In the Create Task window, click OK


Back to top



The task is displayed in the list.


Back to top




Article is closed for comments.