BASH script: Save unsynced data to disk

Displays amount of data waiting to be written to disk(s) and invokes sync(1) to force changed blocks to disk and update the super block.
#!/bin/bash
saved=`grep ^Dirty /proc/meminfo | sed 's/Dirty\:[[:space:]]*//g`
echo "Syncing $size of unsaved data to disk(s)."
sync

Example output:
sairon@arch-sd:~$ dirty
Syncing 84 kB of unsaved data to disk(s). 

Thanks to:
http://www.commandlinefu.com/commands/view/9105/find-out-how-much-data-is-waiting-to-be-written-to-disk

No comments:

Post a Comment