Automated nightly defrags on Windows XP…

On my machine I have two partitions : C & D. The C partition has the OS, all Programs like Office, IDEA, Oracle, etc on it. The D drive just has data – mostly source code, project directories, personal files, etc.

I’ve noticed that when I’m doing development, the D drive gets fragmented very quickly (even in one days time). After a full day’s coding, I usually manage to create 1000 or so fragmented files (even when the machine has been completely defragged the day before). This is after doing full rebuilds, re-installations of the appserver (we have an ant target to completely wipe out our Jboss directory and re-install it), pulls from CVS, etc..

Anyway – you can setup Windows built in defrag tool to run on a recurring basis. Here’s how :

Create a batch file (e.g. c:\bin\DefragLocalDrives.cmd) with the contents similar to the following (customize to your local drive structure):

defrag /v /f c: > d:\temp\Defrag_C.txt
defrag /v /f d: > d:\temp\Defrag_D.txt

Now create a scheduled task to run this batch file. Goto Start | Control Panel | Scheduled Tasks and click on “Add Scheduled Task” Point the new scheduled task at the batch file you created in step 1 and set up the recurrence to your preferred frequency.

I set mine up to run every morning at 4:30 AM. At first I thought this would be overkill, but I’ve noticed that when doing development I always have some fragmentation, even after only a day’s use.

That’s it…


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: