sync Command in Unix

sync 属于 System Administration Commands,负责系统管理工作的。在 SUN Solaris 2.9 中的 man 信息如下:

NAME
     sync - update the super block
SYNOPSIS
     sync
DESCRIPTION
     sync executes the sync system primitive. If the system is to be  stopped,  sync  must  be  called  to  insure file system integrity. It will flush  all  previously  unwritten  system buffers  out  to disk, thus assuring that all file modifications up to that  point  will  be  saved.  See  sync(2)  for details.

Unix 内核为了达到最佳的磁盘操作效率,会把需要写入到磁盘的数据先在内存中缓存起来,在合适的时候才真正写入到磁盘,这在绝大多数情况都是没有问题的,Unix 通过缓存机制提高了系统的效率。

但是如果系统出现宕机、断电等不可抗力的事情,那么缓存中的数据就存在不被更新的危险。为了避免发生这种情况,Unix 系统提供重启时自动把缓冲区的内容同步到磁盘中。同时我们也可以手工去执行sync命令,强制将内存中的文件缓冲内容写到磁盘,正如上文红色部分所说的。

转载于:https://www.cnblogs.com/orientsun/archive/2012/07/11/2585747.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值