LOGO

Schedule Disk Cleanup in Windows Server 2008 - Part 2

January 26, 2010
Schedule Disk Cleanup in Windows Server 2008 - Part 2

Maintaining Server Efficiency with Scheduled Disk Cleanup

Ensuring your servers remain optimized is straightforward with Disk Cleanup, and automating this process through scheduling simplifies the task considerably.

Having previously detailed Disk Cleanup in a prior article, we can now leverage the capability to define preset parameters for its execution. To initiate this, input the following command into the Run dialog:

cleanmgr.exe /sageset:1

A numerical value ranging from 1 to 65535 can be utilized for assignment; we will begin with preset number 1.

Upon pressing enter, the Disk Cleanup Settings dialog box will appear, requesting you to specify the file types for deletion. After making your selections, confirm by clicking OK.

disk-cleanup-in-server-2008-part-2-schedule-a-cleanup-1.jpg

Automating Cleanup with Task Scheduler

To schedule the cleanup, open Task Scheduler either by locating the program or by typing "Task Scheduler" into the Run dialog box.

disk-cleanup-in-server-2008-part-2-schedule-a-cleanup-2.jpg

Within Task Scheduler, select "Create Task" from the right-hand panel.

disk-cleanup-in-server-2008-part-2-schedule-a-cleanup-3.jpg

Assign the name "DiskClean" to your task. Then, select the option "Run whether user is logged on or not" to ensure the task executes regardless of the current user session. The task will be assigned to an administrator account, as this account possesses the necessary permissions for its completion.

disk-cleanup-in-server-2008-part-2-schedule-a-cleanup-4.jpg

Configuring Task Triggers

Navigate to the "Triggers" tab and click the "New…" button.

disk-cleanup-in-server-2008-part-2-schedule-a-cleanup-5.jpg

While more granular trigger configurations are possible, for this example, we will schedule the task to run at a specific time daily.

disk-cleanup-in-server-2008-part-2-schedule-a-cleanup-6.jpg

Defining the Action

Switch to the "Actions" tab and click the "New…" button.

disk-cleanup-in-server-2008-part-2-schedule-a-cleanup-7.jpg

Click the "Browse…" button adjacent to the "Program/script" field.

disk-cleanup-in-server-2008-part-2-schedule-a-cleanup-8.jpg

Within the System Tools directory, select "Disk Cleanup" and press OK.

disk-cleanup-in-server-2008-part-2-schedule-a-cleanup-9.jpg

To apply the previously configured settings for condition #1, enter the following into the "Add arguments" box:

/sagerun:1

Then, click OK.

disk-cleanup-in-server-2008-part-2-schedule-a-cleanup-10.jpg

After adding the program to the Actions, click the "OK" button at the bottom of the "Create Task" window. You will be prompted to enter the password for the user account assigned to the task under the "General" tab.

disk-cleanup-in-server-2008-part-2-schedule-a-cleanup-11.jpg

The new task may take a few moments to appear, but it can then be viewed and edited within the "Active Tasks" pane of Task Scheduler.

disk-cleanup-in-server-2008-part-2-schedule-a-cleanup-12.jpg

Task Scheduler offers considerable flexibility, and this demonstrates how it can be effectively utilized to achieve desired outcomes, such as maintaining a clutter-free server environment.

#Disk Cleanup#Windows Server 2008#schedule#automate#disk space#server maintenance