Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flush disk write cache from Windows CLI

Does anyone know how to flush the disk write cache data from the cache manager for the current directory (or any given file or directory, for that matter), from a Windows command line?

like image 848
Brian Avatar asked Sep 17 '08 17:09

Brian


People also ask

Should I turn off Windows Write-cache buffer flushing on HDD?

If you're more concerned with performance than the integrity of your data, turning off write-cache buffer flushing skips that extra command to flush the internal RAM buffer.

Should I disable write caching Windows 10?

Keep in mind that writing to disk is slow, so "write caching" buffers data in memory and only persists it to disk after a timeout or after a buffer is full. This is probably giving you a performance boost, don't disable it unless you know what you are doing.


1 Answers

I found the SysInternals Sync worked well for me - although it flushes ALL cache, not just for the specific folder.

Example of usage:

IF EXIST Output RD /S /Q Output && Sync && MD Output

By default it flushes all cached data for all drives - you can specify command-line options to restrict which drives but you cannot restrict it to just specific folders.

Without it I would often get Access denied errors because the MD was trying to create a new folder while the system was still in the process of deleting the old one.

like image 159
OldCurmudgeon Avatar answered Sep 27 '22 22:09

OldCurmudgeon