Functions of Unix/Linuxsync commands
Write cache command -- sync
After the unix system is started with the reboot command, the system prompts an error message, and some applications cannot work normally. After carefully checking the system files and comparing them with the initial correct backup, we found that some files were indeed damaged and we could not find the cause of the file being damaged, finally, I thought of writing the cache command-sync. I didn't run the sync command before reboot, which led to changes in the system file and failed to work normally.
The sync command runs the sync subroutine. If you must stop the system, run the sync command to ensure the integrity of the file system. The sync command writes all unwritten system buffers to the disk, including modified I-nodes, delayed block I/O, and read/write ing files.
The sync Command sends the stored permanent information of the file system to the physical media. Before suspending the system, for example, restarting the machine, you must execute the sync command. The Running Experience of unix systems shows that the sync command should be executed twice to ensure reliability, because the information is not actually written to the disk when the sync command is completed, this command has been executed once. After executing the sync command, wait until the disk work light is off (assuming there is a system work indicator light), and then stop the running of the machine or start the machine.
A unix system can be damaged at any time. Therefore, you must run the sync command before starting or shutting down the machine. Remember that under no circumstances will the execution of the sync command be careful.