How can I tar a file that is being used by another process?

I am archiving the directory. There is a file in this directory that is being written by another process. When I use tar using the tar / Perl Tar module, there is an entry for the file in the archive, but the contents are null.

Before tar files ...

-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

After a U-turn

-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

How can I fix this problem? I want the file to be in the archive with the contents that it has at the time of archiving. This file may be a log file and assume that we cannot close the file descriptor before loading.

+3
source share
5 answers

"Linux", , LVM. LVM, LVM.

LVM , .

LVM:

, LVM, " ". , , . , , , , . , . , , - VFS-lock LVM1 , , 2.6 .

+4

...

cp a a.tmp
cp b b.tmp
cp c c.tmp

... ...

tar *.tmp abc.tar

... :

rm *.tmp

, , , ...

+3

, , . , tar.

+2

, . , tar : , . .

+2

As others have said, it depends on the file system and OS used. syncfirst (or whatever is equivalent on your file system), copy the files to the temp directory and then change them. If the file system does not allow you to copy an open file, then you are SOL; Perl cannot circumvent file system limitations.

0
source

Source: https://habr.com/ru/post/1703421/


All Articles