Wednesday, May 8, 2013
Newbie help: Is this file in use?
You can use "fuser" to check whether any processes have a file open.
$ fuser somefile
somefile: 20719
$ fuser anotherfile
$
Pid 20719 is using somefile, but nothing is using anotherfile.
Pipe queen bonus: I want to compress some old stuff in a directory. Here are some big files:
$du -sk ./* | sort -n | tail -5
71796 ./applog.20120418.gz
349252 ./applog
422952 ./applog.20120613
598672 ./applog.20120627
2816980 ./applog.20130204
Which of the largest five files are in use, if any?
$du -sk ./* | sort -n | tail -5 | awk '{print $2}' | xargs fuser
./applog: 44827
Pid 44827 is using the current applog. The last three are safe to compress.
(Tangent: Compression generally writes to the current filesystem. Therefore, you can't compress in a filesystem that's 100% full.)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment