lsof :list of open files 打开文件数
lsof -n : This option inhibits the conversion of network numbers to host
names for network files. Inhibiting conversion may make lsof
run faster. It is also useful when host name lookup is not
working properly.
-n 命令加上可能会运行的更快一些,和不加一样。
lsof -n |awk '{print $2}'|sort|sort -rn|grep 进程号
linux下more命令:Displays file contents one screen at a time.
more命令做的功能如上图所示,输入q键退出。
打开文件还有一个命令:lsof -p pid|wc -l(pid =process id)
结果一样:
lsof -p (s) This option excludes or selects the listing of files for the processes
whose optional process IDentification (PID) numbers are in the
comma-separated set s - e.g., ‘‘123’’ or ‘‘123,^456’’. (There should
be no spaces in the set.)
查看某个文件是由哪个进程使用命令
例子:
[root@xtz /]# man lsof
[root@xtz /]# lsof /home/monitor/agentJava_2013.04.28
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
java 816 monitor cwd DIR 8,7 4096 19641615 /home/monitor/agentJava_2013.04.28