linux 进程占用的文件夹,linux – 如何对另一个进程正在使用的文件进行tar?

我正在归档一个目录.此目录有一个由另一个进程写入的文件.当我使用Linux tar / Perl Tar模块对此进行tar时,在归档中文件的条目存在,但内容为null.

在tarring文件之前……

-rw-r--r-- 1 irraju dba 28 Feb 18 02:22 a

-rw-r--r-- 1 irraju dba 25 Feb 18 02:23 b

-rw-r--r-- 1 irraju dba 29 Feb 18 03:38 c

解开后

-rw-r--r-- irraju/dba 28 2009-02-18 02:22:58 a

-rw-r--r-- irraju/dba 25 2009-02-18 02:23:17 b

-rw-r--r-- irraju/dba 0 2009-02-18 03:33:12 c

我该如何解决这个问题?我希望文件在存档中包含存档时的内容.此文件可以是日志文件,并假设我们无法在tarring之前关闭文件句柄.

解决方法:

当您使用“Linux”标记问题时,您可能正在使用LVM分区.

如果您确实在LVM分区上运行,则可以使用LVM快照功能.

A wonderful facility provided by LVM is ‘snapshots’. This allows the administrator to create a new block device which presents an exact copy of a logical volume, frozen at some point in time. Typically this would be used when some batch processing, a backup for instance, needs to be performed on the logical volume, but you don’t want to halt a live system that is changing the data. When the snapshot device has been finished with the system administrator can just remove the device. This facility does require that the snapshot be made at a time when the data on the logical volume is in a consistent state – the VFS-lock patch for LVM1 makes sure that some filesystems do this automatically when a snapshot is created, and many of the filesystems in the 2.6 kernel do this automatically when a snapshot is created without patching.

标签:linux,perl,archive,tar

来源: https://codeday.me/bug/20190717/1485699.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值