Forum Discussion
Windows Server ScheduledDefrag Task Schedule not running
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 -$
- Dave PatrickFeb 28, 2019MVP
Yes, that looks correct. Might also check the task Conditions tab and remove the checks.
- NivleeFeb 28, 2019Copper Contributor
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.
- Dave PatrickFeb 28, 2019MVP
You can find most here.
https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/defrag
The $ may have to do with priority. If it runs Ok using defrag.exe -c then I'd probably go with that as acceptable.
- johnneuMar 01, 2021Brass Contributor
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 > DEFRAGIf 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!
JohnNeu