Windows Server ScheduledDefrag Task Schedule not running

New Contributor

All my Windows server (2008 R2 and above) unable to run scheduled task of disk defragmentation? I had turn on the schedule defragmentation in disk defragmenter and set it run on weekly basic, but, it not run. 


In the schedule defragmentation had selected all drive to defragment. Below is one of the server schedule defragmentation sample:

















I need help to solve this problem else i need to manual do all my Windows server disk defragmentation by monthly. 

10 Replies

I'd check the logs at;

Event Viewer\Applications\Microsoft\Windows\TaskScheduler\Operational

(note: log may need to be Enabled in right-hand pane)




Hi Dave,


I checked the event viewer log and history in task scheduler, defrag schedule task had run. However, when we see the "defragment and optimize drive" application, it not defrag and optimize the drive. The drive still in high fragmented rate.


The default action of defrag schedule is correct?

 It using below arguments for the defrag:

%windir%\system32\defrag.exe -c -h -k -g -$

Yes, that looks correct. Might also check the task Conditions tab and remove the checks.



I had removed the all the check inside the condition tab but still not defrag the drive when I run the task schedule.


I noticed if I change the action argument to defrag.exe -c only, then defrag will run.

Can I know what is the meaning of -h -k -g -$? For your information, I using VM server.

You can find most here.


The $ may have to do with priority. If it runs Ok using defrag.exe -c then I'd probably go with that as acceptable.



@Nivlee I came across the same problem on our two Windows 2012 servers. Defrag had never been run and I suspect the reason is that there is no trigger on the ScheduledDefrag task which means it'll never run automatically. Changing the schedule in the optimisation tool from weekly to daily doesn't make any difference. I suspect this is a bug that's been around a long time...



I'm about to add a trigger to run it once a week and see what happens.

I read elsewhere that the -$ flag indicates to defrag.exe that it's running as a scheduled task. It must make it do something different to when run from command line.

In general, some other scheduled task (don't know which) runs ScheduledDefrag. That is why its triggers are empty. I suppose, with some care, triggers could be added. It is too bad that Microsoft allows but doesn't show such cascaded schedules.

I'm seeing all the same symptoms on my server. I just optimized my SSD for the first time since I installed it. Before that, it was showing "Never run".

I too have the blank list of drives under the Choose button.

One extra thing I noticed is that the scheduled task does get triggered and it does log a service start and stop in the System log, but then it seems like nothing else happens. So maybe I need to adjust the scheduled Action as mentioned above.

Your post mentioned Server 2008, but 2008 does not have the arguments of -k -g -$ (in fact, 2008 uses / for arguments, not -), therefore your defrag would immediately exit out with an error status. That likely explains your issue.
Hold your WINDOWS key and tap R and type in CMD and tap enter. There type in DEFRAG.EXE /? and hit enter. Server 2008 has very limited options, nothing for file optimization (which moves the most important files to fastest portions of your disk).
Moreover, you probably should use the Degrag setting that comes in Task Scheduler already. Hold WINDOWS and tap R and type in TASKSCHD.MSC , in the popup's left pane navigate to TASK SCHEDULER LIBRARY > MICROSOFT > WINDOWS > DEFRAG


If you want to optimize your files as well, I suggest Auslogics Disk Defrag, it works on all Windows versions & is very fast when compared to Windows' built-in defrag.exe .  If you can get an old version of Ausologics Disk Defrag, it will lack the annoying options to "buy now" and it also lacks the install of Auslogic's other products as trial versions.  Unfortunately, it cannot be scheduled without purchasing, and the old version lacks optimizations for SSD (solid state) drives.

I hope this helps?
Have a great day!