Creating a Scheduled Task to Delete DNN Log Files Automatically

Overview

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. 

 


 

Prerequisites

Server administrator credentials 

 


 

Process

  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.
     
    mceclip0.png
     
  4. Enter a name for the new folder and click OK.
  5. Right-click on the newly created folder and click Create Task.

    mceclip1.png
     
  6. In the Name field, enter a name for the task.
  7. Enable the Run whether user is logged on or not option.
     
    mceclip2.png
     
  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.
     
    mceclip3.png
     
  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


 

Confirmation

The task is displayed in the list.
 
mceclip4.png

 

Back to top


 

Comments

0 comments

Article is closed for comments.