When to use sync
Use sync to request that pending writes are flushed toward storage. It is not a backup, an integrity verifier or a substitute for cleanly shutting down applications before maintenance.
Syntax
sync [OPTIONS] [FILE...]Square brackets mark optional arguments; an ellipsis means repetition. Replace example file names, user names and server addresses with your own values.
Common options and arguments
Usage examples
Flush pending writes
syncPending filesystem writes are synchronized across the system according to the installed implementation.
Sync a specific file
sync ./report.txtSynchronization is requested for the named file.
Synchronize directory file system
sync -f /srv/appThe filesystem containing the application path is synchronized using the GNU/Linux option.
Notes and limitations
- The command can block while the storage device completes writes.
- sync is not a substitute for proper unmounting and does not create a backup.
Common questions and troubleshooting
Does sync make it safe to unplug a mounted disk?
It is not sufficient on its own. Stop activity and cleanly unmount the filesystem before removing the device.
Does sync confirm that a backup is correct?
No. It concerns write flushing, not the correctness or recoverability of copied data. Verify backup contents and restoration separately.
Further help
Options vary by version and distribution. Check the installed documentation with this command: man sync.