
드래그 앤 드롭을 사용하여 파일을 복사하고 이동합니다. 그 중 한 가지 단점은 파일이 잘못된 위치에 있을 수 있다는 것입니다. 따라서 많은 파일과 폴더를 여러 다른 대상으로 복사/이동했다고 가정해 보겠습니다.
모든 것이 올바른 위치로 복사/이동되었는지 확인하기 위해 모든 것이 끝난 위치를 어떻게 추적할 수 있습니까?
답변1
당신이 요구하는 것은 "파일 시스템 감시자"입니다.
아이워치 
iWatch는 실시간 파일 시스템 모니터링 프로그램입니다. 특정 디렉터리/파일의 변경 사항을 모니터링하고 즉시 이메일 알림을 보내는 간단한 Perl 스크립트입니다. xml 구성 파일에서 dir/file 목록을 읽고 커널(Linux Kernel >= 2.6.13)에서 inotify 지원이 필요합니다.
더 많은 방법이 있지만 이것은 가장 간단한 방법으로 보이며 Ubuntu에 기본으로 제공되며 inotify를 사용합니다(그래서 시스템을 많이 사용하지 않습니다).
iWatch는 두 가지 방법으로 제공됩니다.
- 명령줄
- 악마
로깅을 위한 일부 명령줄 옵션:
-m <email address>
Specify the contact point's email address. Without this option, iwatch will
not send any email notification.
-s <on|off>
Enable or disable reports to the syslog (default is off/disabled)
iwatch /tmp
기본 이벤트로 /tmp 디렉토리의 변경 사항을 모니터링합니다.
iwatch -r -e access,create -m cahya@localhost -x /etc/mail /etc
액세스만 모니터링하고 /etc/mail을 예외로 하여 /etc 디렉토리에 반복적으로 이벤트를 생성하고 이메일 알림을 cahya@localhost로 보냅니다.
iwatch -r -c "(w;ps -ef)|mail -s '%f was changed' cahya@localhost" /bin
/bin 디렉토리를 재귀적으로 모니터링하고 명령을 실행합니다.
iwatch -r -X '\.svn' ~/projects
~/projects 디렉터리를 재귀적으로 모니터링하지만 내부의 .svn 디렉터리는 제외합니다. '-x'는 정의된 경로만 제외할 수 있으므로 일반 '-x' 옵션으로는 이 작업을 수행할 수 없습니다.
예시 구성 파일데몬 모드 모드를 사용할 때. 로깅은 구성 파일의 XML 옵션을 사용하여 수행됩니다.
<config>
<guard email="myadmin@localhost" name="IWatch"></guard>
<watchlist>
<title>Public Website</title>
<contactpoint email="webmaster@localhost" name="Web Master"/>
<path type="single">/var/www/localhost/htdocs</path>
<path type="single" syslog="on">/var/www/localhost/htdocs/About</path>
<path type="recursive">/var/www/localhost/htdocs/Photos</path>
</watchlist>
<watchlist>
<title>Operating System</title>
<contactpoint email="admin@localhost" name="Administrator"/>
<path type="recursive">/etc/apache2</path>
<path type="single">/etc/passwd</path>
<path type="recursive">/etc/mail</path>
<path type="exception">/etc/mail/statistics</path>
<path type="single" filter="shadow|passwd">/etc</path>
</watchlist>
<watchlist>
<title>Only Test</title>
<contactpoint email="root@localhost" name="Administrator"/>
<path type="single" alert="off" exec="(w;ps -ef)|mail -s %f
root@localhost">/tmp/dir1</path>
<path type="single" events="access,close" alert="off" exec="(w;ps -ef)|mail -s %f
root@localhost">/tmp/dir2</path>
<path type="single" events="default,access" alert="off" exec="(w;ps -ef)|mail -s '%f is
accessed' root@localhost">/tmp/dir3</path>
<path type="single" events="all_events" alert="off">/tmp/dir4</path>
</watchlist>
</config>
이 구성을 사용하면 iwatch는 하위 디렉터리 없이 단일 디렉터리를 모니터링하며 /var/www/localhost/htdocs
모든 알림은 연락 지점 webmaster@localhost로 전송됩니다. 그러나 /etc/apache2
IWatch가 시작된 후 나중에 생성된 하위 디렉터리를 포함하여 의 전체 디렉터리 트리를 모니터링합니다 . 모니터링되는 디렉터리 내의 파일이나 하위 디렉터리에 대한 알림을 받지 않으려면 여기에서 예외를 생성할 수도 있습니다.