Is automatic drive optimization and defrag actually running?

Bill Clark 186 Reputation points
2021-06-15T20:10:33.527+00:00

Windows Server 2012 R2 with 3 drives. In the drive Properties, under Optimize Drives I have enabled the automatic option running daily. The last run time for the drives shows as 6/14/21 at 10:14AM. This was a manual optimization done just prior to turning on the automatic option. How do I tell if this is running correctly? Looking in Event Viewer and filtering the Application log for Event ID's 258 & 259, I see several entries for Event ID 258, with the source of Defrag, but they are all time-stamped for yesterdays manual optimization. So, is this running automatically like it should, or not? Also, what time can I expect it to run?
If I open up Task Scheduler, and select Microsoft\Windows\Defrag, I see the system-created task "ScheduledDefrag". It says it is ready and has a Last Run Time of this morning at 3:01AM and says it was completed successfully. I see nothing under Triggers or Next Run Time. Looking closer, the Actions are as follows: %windir%\system32\defrag.exe -c -h -k -g -$. I know what all the parameters except the "-$" are. Somewhere I read that it means that the task is being ran/controlled by another process? Looking under History for this task, I see there was a launch request at 3:01:23AM, followed by some other actions only to end with Task Completed at 3:01:26AM.
Can anyone shed some light into what Windows is doing here? Am I looking at the wrong Event IDs, or maybe the wrong logs? Is it best to turn off the automatic option and edit the existing scheduled task to run on a set time, minus the "-$"? TIA

Windows Server 2012
Windows Server 2012
A Microsoft server operating system that supports enterprise-level management, data storage, applications, and communications.
1,579 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Teemo Tang 11,391 Reputation points
    2021-06-16T02:06:01.553+00:00

    No, you get the correct Event ID.

    The defragmentation is 100% being performed (System Restore is enabled) and it shows up in the Event Viewer as "The storage optimizer successfully completed defragmentation on Windows (C: ) and "The storage optimizer successfully completed defragmentation on WINRE_DRV." These events are preceded with a "The storage optimizer successfully completed retrim on Windows (C: ) event. All three are listed as Event ID 258 and Task Category is listed as none.

    If your device using SSD, drive optimization does not defrag the SSD, but optimizing it:
    There are some important optimizations, but Windows performs them all automatically. If you used an SSD with Windows XP or Vista, you needed to manually enable TRIM, which ensures your SSD can clean up deleted files and stay speedy. However, ever since Windows 7, Windows has automatically enabled TRIM for any drive it detects as solid-state.

    About your concern: “Is it best to turn off the automatic option and edit the existing scheduled task to run on a set time, minus the "-$"? TIA”
    I ever read an article and feel helpful, I think you could get your answer from it
    https://www.hanselman.com/blog/the-real-and-complete-story-does-windows-defragment-your-ssd

    -------------------------------------------------------------------------------------

    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Information posted in the given link is hosted by a third party. Microsoft does not guarantee the accuracy and effectiveness of information.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.