목록에 추가된 디렉토리의 바이너리 파일을 바꿀 때마다. intoifywait
동일한 로그가 여러 번 나타납니다. 그러나 .js
등과 같은 다른 파일의 경우 잘 작동합니다. 다음은 로그입니다
monitor_status DELETE 2018-08-12 14:07:54
monitor_status CREATE 2018-08-12 14:07:54
monitor_status MODIFY 2018-08-12 14:07:54
monitor_status MODIFY 2018-08-12 14:07:54
monitor_status MODIFY 2018-08-12 14:07:54
monitor_status MODIFY 2018-08-12 14:07:54
monitor_status MODIFY 2018-08-12 14:07:54
monitor_status MODIFY 2018-08-12 14:07:54
monitor_status MODIFY 2018-08-12 14:07:54
monitor_status MODIFY 2018-08-12 14:07:54
monitor_status MODIFY 2018-08-12 14:07:54
monitor_status MODIFY 2018-08-12 14:07:54
monitor_status MODIFY 2018-08-12 14:07:54
monitor_status MODIFY 2018-08-12 14:07:54
monitor_status MODIFY 2018-08-12 14:07:54
monitor_status MODIFY 2018-08-12 14:07:54
monitor_status MODIFY 2018-08-12 14:07:54
monitor_status MODIFY 2018-08-12 14:07:54
monitor_status MODIFY 2018-08-12 14:07:54
monitor_status MODIFY 2018-08-12 14:07:54
monitor_status MODIFY 2018-08-12 14:07:54
monitor_status MODIFY 2018-08-12 14:07:54
monitor_status MODIFY 2018-08-12 14:07:54
monitor_status MODIFY 2018-08-12 14:07:54
monitor_status MODIFY 2018-08-12 14:07:54
monitor_status MODIFY 2018-08-12 14:07:54
monitor_status MODIFY 2018-08-12 14:07:54
monitor_status MODIFY 2018-08-12 14:07:54
monitor_status MODIFY 2018-08-12 14:07:54
monitor_status MODIFY 2018-08-12 14:07:54
monitor_status MODIFY 2018-08-12 14:07:54
monitor_status MODIFY 2018-08-12 14:07:54
monitor_status MODIFY 2018-08-12 14:07:54
hello CREATE 2018-08-12 14:09:38
monitor_status DELETE 2018-08-14 07:02:52
monitor_status CREATE 2018-08-14 07:02:52
monitor_status MODIFY 2018-08-14 07:02:52
monitor_status MODIFY 2018-08-14 07:02:52
monitor_status MODIFY 2018-08-14 07:02:52
monitor_status MODIFY 2018-08-14 07:02:52
monitor_status MODIFY 2018-08-14 07:02:52
답변1
inotifywait는 시스템에 대한 각 "쓰기"를 표시합니다. 간단한 cp(내 테스트 시스템과 ext4에서)인 경우 64k마다 수정 작업을 수행합니다.
# dd if=/dev/urandom of=test bs=64K count=1
1+0 records in
1+0 records out
65536 bytes (66 kB) copied, 0.00178826 s, 36.6 MB/s
# cp test test2
다음을 제공합니다(복사본만 해당):
./ OPEN test
./ MODIFY test2
./ OPEN test2
./ ACCESS test
./ MODIFY test2
./ CLOSE_WRITE,CLOSE test2
./ CLOSE_NOWRITE,CLOSE test
하지만:
# dd if=/dev/urandom of=test bs=128K count=1
1+0 records in
1+0 records out
131072 bytes (131 kB) copied, 0.00251142 s, 52.2 MB/s
# cp test test2
다음을 제공합니다(복사본만 해당):
./ OPEN test
./ MODIFY test2
./ OPEN test2
./ ACCESS test
./ MODIFY test2
./ ACCESS test # one more time
./ MODIFY test2 # one more time
./ CLOSE_WRITE,CLOSE test2
./ CLOSE_NOWRITE,CLOSE test
동일한 내용이 strace에 표시됩니다.
# 64k file
open("test", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=65536, ...}) = 0
open("test2", O_WRONLY|O_TRUNC) = 4
fstat(4, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
fadvise64(3, 0, 0, POSIX_FADV_SEQUENTIAL) = 0
read(3, "\374\207\343\36\263\17\224A\361R\271\333\f\1\342\236K\n\270\f\250x}/\346}a\221\237\323\315\32"..., 65536) = 65536
write(4, "\374\207\343\36\263\17\224A\361R\271\333\f\1\342\236K\n\270\f\250x}/\346}a\221\237\323\315\32"..., 65536) = 65536
read(3, "", 65536) = 0
close(4) = 0
close(3) = 0
# 128k file
open("test", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=131072, ...}) = 0
open("test2", O_WRONLY|O_TRUNC) = 4
fstat(4, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
fadvise64(3, 0, 0, POSIX_FADV_SEQUENTIAL) = 0
read(3, "pK;\376\326\17gx\20\227\320\204\7\6:\233r\0\215\215b\r?2\31\206\331\16q\205\324\22"..., 65536) = 65536
write(4, "pK;\376\326\17gx\20\227\320\204\7\6:\233r\0\215\215b\r?2\31\206\331\16q\205\324\22"..., 65536) = 65536
read(3, "\37515X\225\230xL\nhW\"\240\315P]\376\347#\10\341\25\215\212:f9q\313\255\32\n"..., 65536) = 65536
write(4, "\37515X\225\230xL\nhW\"\240\315P]\376\347#\10\341\25\215\212:f9q\313\255\32\n"..., 65536) = 65536
read(3, "", 65536) = 0
close(4) = 0
파일 시스템에 따라 달라지는지는 알 수 없지만 cp는 파일을 고정된 크기의 부분(내 경우에는 64k)으로 복사하고 각 부분이 작성될 때 "수정" 이벤트를 볼 수 있습니다.