Caffeine Induced
The Weblog of Lance Hankins
 
Wednesday June 25, 2003
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):

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…

Posted by lhankins ( Jun 25 2003, 12:00:00 AM CDT ) Permalink