Purpose Description
The Linux kernel to achieve optimal disk operation efficiency, the data that needs to be written to disk is now cached in memory and is actually written to disk at the right time, which is not problematic in most cases and improves the efficiency of the system, but if the system is machine, power off, There will be some file content that will not be saved. When the Linux system shuts down or restarts, the contents of the buffer are automatically synchronized to the disk automatically. We can also manually execute the sync command, forcing the file buffer in memory to be written to disk, which is implemented by calling the sync system call. (Flush file system buffers.) Synchronize data on disk with memory. Force changed blocks to disk, update the super blocks. ' Sync ' writes any data buffered into memory out to disk. this can Include (but isn't limited to) modified Superblocks, modified inodes, and delayed reads and writes. I Mplemented by the kernel; The ' Sync ' program does nothing but exercise's ' sync ' system call. the kernel keeps data in memory to avoid Doing (relatively slow) disk reads and writes. this improves performance, but if the computer crashes, data May is L OST or the file system corrupted as a result. The ' Sync ' command ensures everything in memory be written to Disk.) However, I do not think it is necessary for us to execute this command in general, as the Linux kernel will automatically synchronize the data in memory to disk as soon as possible, and who knows when to lose power or machine.
Common Ways
Format: Sync
Forces the file buffer content in memory to be written to disk.
using the sample Example One
[Root@web ~]# Sync
[Root@web ~]#