我使用过的Linux命令之sync - 强制将内存中的文件缓冲内容写到磁盘
2011-10-31 16:57
881 查看
本文链接:/article/4053476.html (转载请注明出处)
Linux内核为了达到最佳的磁盘操作效率,会把需要写入到磁盘的数据现在内存中缓存起来,在合适的时候才真正写入到磁盘中,这在绝大多数情况都是没有任何问题的,而且提高了系统的效率,但是如果系统当机、掉电,就会有些文件内容不会保存下来。在Linux系统关机或者重启时,会自动把缓冲区的内容自动同步到磁盘中。我们也可以手工去执行sync命令,强制将内存中的文件缓冲内容写到磁盘,这个命令是通过调用sync系统调用来实现的。(flush
file system buffers。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
强制将内存中的文件缓冲内容写到磁盘。
[root@web ~]# sync
[root@web ~]#
1. 在以前使用Unix(SCO Unix, Sun OS)的时候,那些人教我们使用sync命令,所以记住了它,有些文章也说在关闭或重启系统之前要多次执行sync命令,有的说要2此,有的说最好4次。各位看官,你们怎么看待这个问题,欢迎留言赐教。
【1】肚子网 linux命令sync用法详解
http://www.duzi.cn/article/2010-3-12/223585-1.htm
【2】loongene的博客 Linux sync命令的作用
http://blog.sina.com.cn/s/blog_53689eaf0100o8b4.html
【3】IT INF Linux sync命令详解
http://www.itinf.com/bbs/viewthread.php?tid=66500&extra=page%3D1
【4】CCF技术论坛 【求助】LINUX关机之前,是否一定要sync呢?
https://bbs.et8.net/bbs/archive/index.php/t-374736.html
用途说明
Linux内核为了达到最佳的磁盘操作效率,会把需要写入到磁盘的数据现在内存中缓存起来,在合适的时候才真正写入到磁盘中,这在绝大多数情况都是没有任何问题的,而且提高了系统的效率,但是如果系统当机、掉电,就会有些文件内容不会保存下来。在Linux系统关机或者重启时,会自动把缓冲区的内容自动同步到磁盘中。我们也可以手工去执行sync命令,强制将内存中的文件缓冲内容写到磁盘,这个命令是通过调用sync系统调用来实现的。(flushfile system buffers。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强制将内存中的文件缓冲内容写到磁盘。
使用示例
示例一
[root@web ~]# sync[root@web ~]#
示例二
问题思考
1. 在以前使用Unix(SCO Unix, Sun OS)的时候,那些人教我们使用sync命令,所以记住了它,有些文章也说在关闭或重启系统之前要多次执行sync命令,有的说要2此,有的说最好4次。各位看官,你们怎么看待这个问题,欢迎留言赐教。
相关资料
【1】肚子网 linux命令sync用法详解http://www.duzi.cn/article/2010-3-12/223585-1.htm
【2】loongene的博客 Linux sync命令的作用
http://blog.sina.com.cn/s/blog_53689eaf0100o8b4.html
【3】IT INF Linux sync命令详解
http://www.itinf.com/bbs/viewthread.php?tid=66500&extra=page%3D1
【4】CCF技术论坛 【求助】LINUX关机之前,是否一定要sync呢?
https://bbs.et8.net/bbs/archive/index.php/t-374736.html
相关文章推荐
- Linux命令之sync - 强制将内存中的文件缓冲内容写到磁盘
- Linux命令之sync - 强制将内存中的文件缓冲内容写到磁盘
- Linux命令之sync - 强制将内存中的文件缓冲内容写到磁盘
- Linux命令之sync - 强制将内存中的文件缓冲内容写到磁盘
- Linux sync --强制将内存中的文件缓冲内容写到磁盘
- Linux 服务器 Shell 命令 查找大文件 磁盘占用情况 内存使用情况
- linux 操作系统中cat查看文件内容命令的使用
- Linux 查看磁盘分区、文件系统、磁盘的使用情况相关的命令和工具介绍
- Linux 查看磁盘分区、文件系统、磁盘的使用情况相关的命令和工具介绍
- Linux 查看磁盘分区、文件系统、磁盘的使用情况相关的命令和工具介绍 by 北南南北
- Linux的经典文本编辑器vi的使用, 基本的文件内容查看命令
- linux 操作系统中less显示查看文件内容命令的使用
- Linux 查看磁盘分区、文件系统、磁盘的使用情况相关的命令和工具介绍
- linux如何使用umount命令强制卸载文件系统
- linux 操作系统中move查看文件内容命令的使用
- 文件缓冲内容写到磁盘
- Linux下使用du命令查看文件或目录占用磁盘空间大小
- 关于linux下查看磁盘,内容,CPU使用情况的命令
- Linux命令-使用echo命令在文件的末尾追加内容
- Linux—使用Shell命令清空或删除大文件内容的方法