Feb 26 2019 01:58 AM
Feb 26 2019 01:58 AM
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.
Feb 27 2019 05:57 PM
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 -$
Feb 27 2019 06:39 PM
Yes, that looks correct. Might also check the task Conditions tab and remove the checks.
Feb 27 2019 07:28 PM
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.
Feb 27 2019 07:46 PM
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.
Jan 05 2020 02:51 PM
@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.
Jan 05 2020 03:17 PM
Jan 16 2020 08:20 AM
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.
Aug 12 2020 03:46 PM
Mar 01 2021 08:40 AM - edited Mar 01 2021 08:45 AM
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!
Apr 16 2023 08:01 PM
Hi, I saw this unresolved thread, and just want to add that:
This is why servers no longer defragment automatically. I do not know what the official guidance is for server operators. My guess is that you would alter the task or create a new custom one that fits your environment. That would also involve choosing which disks to optimize and which to skip, and choosing what time to run at to avoid conflicting with backups and to not optimize all VMs simultaneously. This complexity may be why it's effectively turned off by default.
Regarding the missing triggers and schedule: