1

When I need to do echo 3 > /proc/sys/vm/drop_caches with a sync beforehand, is it better to use

sync && echo 3 > /proc/sys/vm/drop_caches or

sync ; echo 3 > /proc/sys/vm/drop_caches.

Does it even matter because both commands are safe for the filesystem data? Or might the second version lose data in the process?

micxer
  • 38
  • 7

1 Answers1

1

More like... you shouldn't need to do this at all. What's the root or underlying performance problem you're trying to correct with the drop_caches routine?

For the record, sync ; echo 3 > /proc/sys/vm/drop_caches is fine.

ewwhite
  • 197,159
  • 92
  • 443
  • 809
  • I wuld argue that the sync is superfluous as when dropping the cache the system will need to sync the contents to disk anyway. You don't lose data whatever you do. – wurtel Dec 14 '15 at 13:09
  • I stumbled upon this gem while migrating and old system to a VM. There are some long running processes that seem to leak memory over time. – micxer Dec 16 '15 at 08:39