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
- Log in to the site server as an administrator.
- Launch the Task Scheduler.
- In Windows, click Start.
- Press Enter.
- Right-click on the Task Scheduler Library and select New folder.
- Enter a name for the new folder and click OK.
- Right-click on the newly created folder and click Create Task.
- In the Name field, enter a name for the task.
- Enable the Run whether user is logged on or not option.
- Go to the Triggers tab and click New Trigger.
- From the Begin the task drop-down menu, select On a schedule.
- Under the Settings section, select the frequency to run the task.
- Click OK.
- 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.
ForFilesinto the Program/script text box.
ForFiles is a computer software utility for Microsoft Windows, which selects files and runs a command on them.
- 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
/p "C:\DBA\SQLTrace" /s /d -90 /c "cmd /c del @file"
- In the Create Task window, click OK.
The task is displayed in the list.