inotify-tools

提供: セキュリティ
2013年10月5日 (土) 17:50時点におけるDaemon (トーク | 投稿記録)による版 (ページの作成:「inotify-tools とは、inotify のシンプルなインターフェースを提供する Linux 向けのコマンドラインプログラムのセットで...」)

(差分) ←前の版 | 最新版 (差分) | 次の版→ (差分)
移動: 案内検索
スポンサーリンク

inotify-tools とは、inotify のシンプルなインターフェースを提供する Linux 向けのコマンドラインプログラムのセットです。

読み方

inotify-tools
あいのーてぃふぁい つーるず

概要

inotifywatch は、inotify を使用して、ファイルシステムへのアクセスの統計情報を集めます。 inotifywatch は、Linuxinotify(7)インターフェースを使用して、ファイルシステムのイベントをリッスンします。それぞれのファイルやディレクトリのイベントを受取、サマリーをカウントして出力します。

inotifywait は、inotify を使用して、ファイルの変更を待ちます。 inotifywait は、Linuxinotify(7)インターフェースを使用して、ファイルの変更を待ちます。シェルスクリプトによってファイルが変更されるのと待つのに最適です。イベントが発生すると、すぐに終了します。

パッケージの内容

inotify-tools のバージョン 3.13のパッケージの内容です。

$ rpmquery -l inotify-tools
/usr/bin/inotifywait
/usr/bin/inotifywatch
/usr/lib64/libinotifytools.so.0
/usr/lib64/libinotifytools.so.0.4.1
/usr/share/doc/inotify-tools-3.13
/usr/share/doc/inotify-tools-3.13/AUTHORS
/usr/share/doc/inotify-tools-3.13/COPYING
/usr/share/doc/inotify-tools-3.13/ChangeLog
/usr/share/doc/inotify-tools-3.13/NEWS
/usr/share/doc/inotify-tools-3.13/README
/usr/share/man/man1/inotifywait.1.gz
/usr/share/man/man1/inotifywatch.1.gz

インストール

CentOSにインストールする場合

CentOSyum コマンドでインストールする場合。

sudo yum -y  install inotify-tools

使い方

inotifywatch

2つのターミナルを用意します。

1つ目のターミナルで inotifywatch を実行します。

$ inotifywatch -r /tmp/
Establishing watches...
Finished establishing watches, now collecting statistics.

2つめのターミナルで、監視対象のディレクトリのファイルに対して、コマンドを実行します。

$ echo hoge >> /tmp/inotify-test/abc

1つめのターミナルで C-c で inotifywatch を終了させます。

$ inotifywatch -r /tmp/
Establishing watches...
Finished establishing watches, now collecting statistics.
^C
total  modify  close_write  open  filename
3      1       1            1     /tmp/inotify-test/

inotifywait

これは、inotifywait でディレクトリ /tmp を監視する例です。

$ inotifywait /tmp
Setting up watches.
Watches established.
/tmp/ CREATE man.UI49mr

inotifywait によるシステム監視

/etc を監視する例です。

sudo inotifywait -m -e create,delete,modify,move,attrib \
--format '%T %w %f %e' -r --timefmt '%F %T' /etc

/etc にファイルを作成してみます。

sudo touch /etc/XXX

以下のように inotifywait によって検知されます。

2013-10-05 17:47:30 /etc/ XXX CREATE
2013-10-05 17:47:30 /etc/ XXX ATTRIB

関連項目




スポンサーリンク