Linux命令之sync - 强制将内存中的文件缓冲内容写到磁盘
2012-05-29 19:01
886 查看
用途说明
Linux内核为了达到最佳的磁盘操作效率,会把需要写入到磁盘的数据现在内存中缓存起来,在合适的时候才真正写入到磁盘中,这在绝大多数情况都是没有任何问题的,而且提高了系统的效率,但是如果系统当机、掉电,就会有些文件内容不会保存下来。在Linux系统关机或者重启时,会自动把缓冲区的内容自动同步到磁盘中。我们也可以手工去执行sync命令,强制将内存中的文件缓冲内容写到磁盘,这个命令是通过调用sync系统调用来实现的。(flush file systembuffers。Synchronize data on disk with memory。Force changed blocks to disk, update the super block.`sync' writes any data buffered in memory out to disk. This can include (but is not limited to) modified superblocks, modified inodes, and delayed reads and
writes. This must be implemented by the kernel; The `sync' program does nothing but exercise the `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 be lost or the file system corrupted as a result. The `sync' command ensures everything in memory is written to disk.)但是,我认为一般情况下我们是没有必要去执行这个命令的,因为Linux内核会尽快让内存中的数据自动同步到磁盘上去,而且,谁又会知道什么时候会掉电或当机呢?
常用方式
格式:sync强制将内存中的文件缓冲内容写到磁盘。
原文地址:/article/4053476.html
相关文章推荐
- 我使用过的Linux命令之sync - 强制将内存中的文件缓冲内容写到磁盘
- Linux命令之sync - 强制将内存中的文件缓冲内容写到磁盘
- Linux命令之sync - 强制将内存中的文件缓冲内容写到磁盘
- Linux命令之sync - 强制将内存中的文件缓冲内容写到磁盘
- Linux sync --强制将内存中的文件缓冲内容写到磁盘
- sync命令_Linux sync 命令用法详解:用于强制被改变的内容立刻写入磁盘
- Linux 服务器 Shell 命令 查找大文件 磁盘占用情况 内存使用情况
- 文件缓冲内容写到磁盘
- Linux查找文件内容的常用命令方法
- Linux命令学习(八):比较文件内容的命令
- Linux下查看文件内容的命令
- Linux查找文件内容的常用命令方法
- linux下的find文件查找命令与grep文件内容查找命令
- linux下的find文件查找命令与grep文件内容查找命令
- linux 不删除文件,清空文件内容命令
- Linux 查看文件内容的命令
- linux下的find文件查找命令与grep文件内容查找命令
- linux 下查找文件或者内容常有命令
- Linux命令:磁盘和文件系统管理
- less命令_Linux less 命令用法详解:分屏上下翻页浏览文件内容