4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Ubuntuでrmすると、"Text file busy"で削除ができない、トラブルシューティング

Posted at

環境

Vagrant + Ubuntu 16.04.5 LTS

はじめに

ディレクトリを削除しようとしたら、ファイルが掴まれていて、削除ができないようです。このようなケースのトラブルシューティング。

$ rm -rf test02
rm: cannot remove 'test02/db/development.sqlite3': Text file busy

対応方法

削除したいファイルのプロセス番号を調べます。fuserコマンドは、指定したファイルが使用しているプロセス番号を調べるコマンドです。

$fuser ./test02/db/development.sqlite3
/vagrant/test02/db/development.sqlite3:  5356

プロセス番号:5356が、該当のファイルで本当に使われている事を確認します。psコマンドは、現在動いている全てのプログラムのプロセス番号を一覧表示するコマンドです。

$ps -f | grep 5356
vagrant   5356  2005  0 13:23 pts/0    00:00:00 sqlite3 ./db/development.sqlite3

稼働中のプロセスを強了させます。-9は、シグナルIDといって、これをつけると、強制終了という意味になります。くれぐれも、終了させるプロセス番号は間違わないように。

$kill -9 5356

これで、削除できるようになりました。

$rm -rf test02

参考URL

4
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?