プロが教えるわが家の防犯対策術!

ロックの情報を取得したいのですがどのようなコマンドを実行すればよろしいでしょうか?

ロック
 どのファイルがどのプログラムによってロックされているか?

ご教授の程、宜しくお願いいたします。

A 回答 (1件)

rootでしか実行出来ませんがlsof(8)はどうですかね?



以下のlsofのオンラインマニュアルの抜粋にある通り、lsofを実行し出力のFDの項目を見ればロックされているかどうかが分かります。

------8<-------8<------8<-------8<-------8<------
FD is followed by one of these characters, describing the
mode under which the file is open:

  r for read access;
  w for write access;
  u for read and write access;
  space if mode unknown and no lock character follows;
  `-' if mode unknown and lock character follows.

The mode character is followed by one of these lock characters, describing the type of lock applied to the file:

  N for a Solaris NFS lock of unknown type;
  r for read lock on part of the file;
  R for a read lock on the entire file;
  w for a write lock on part of the file;
  W for a write lock on the entire file;
  u for a read and write lock of any length;
  U for a lock of unknown type;
  x for an SCO OpenServer Xenix lock on part of the file;
  X for an SCO OpenServer Xenix lock on the entire file;
  space if there is no lock.
------8<-------8<------8<-------8<-------8<------

以下、Fedora CORE 3での実行例です。
(たぶん、見難いとは思いますが。。。)
------8<-------8<------8<-------8<-------8<------
# lsof | egrep " [0-9]*[rwu\-][NrRwWuUxX] "
nifd 3563 root 4uW REG 253,0 5 1080653 /var/run/nifd.pid
mDNSRespo 3593 nobody 10uW REG 253,0 5 1080655 /var/run/mDNSResponder.pid
sendmail 3793 root 5wW REG 253,0 33 1080751 /var/run/sendmail.pid
sendmail 3801 smmsp 4wW REG 253,0 50 1084009 /var/run/sm-client.pid
anacron 3905 root 4uW REG 253,0 9 1084745 /var/spool/anacron/cron.daily
anacron 3905 root 5uW REG 253,0 0 1084747 /var/spool/anacron/cron.monthly
atd 3914 root 3uW REG 253,0 5 1084699 /var/run/atd.pid
gconfd-2 4562 lean 12wW REG 253,0 649 214373 /tmp/gconfd-lean/lock/0t1112092337ut33437u500p4562r2059905881k3220550124 (deleted)
------8<-------8<------8<-------8<-------8<------
    • good
    • 0
この回答へのお礼

lsofを使うのですね。私の環境には入っていなかったようなのでインストールして試してみます。
ありがとうございました。

お礼日時:2005/04/01 17:03

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!