我是靠谱客的博主 文静发箍,这篇文章主要介绍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

最后

以上就是文静发箍最近收集整理的关于linux 进程占用的文件夹,linux – 如何对另一个进程正在使用的文件进行tar?的全部内容,更多相关linux内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(147)

评论列表共有 0 条评论

立即
投稿
返回
顶部