linux查看文件被哪个进程占用?
1> 如果文件是端口号
netstat -ntlp | grep portNum
[root@localhost root]# netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0.0.0.0: 0.0.0.0:* LISTEN -
tcp 0.0.0.0: 0.0.0.0:* LISTEN -
tcp 0.0.0.0: 0.0.0.0:* LISTEN -
tcp 0.0.0.0: 0.0.0.0:* LISTEN /gmond
tcp 0.0.0.0: 0.0.0.0:* LISTEN /svnserve
tcp 0.0.0.0: 0.0.0.0:* LISTEN /rpcbind
tcp 0.0.0.0: 0.0.0.0:* LISTEN /rpc.mountd
tcp 0.0.0.0: 0.0.0.0:* LISTEN /rsync
tcp 0.0.0.0: 0.0.0.0:* LISTEN /sshd
tcp 127.0.0.1: 0.0.0.0:* LISTEN /cupsd
tcp 0.0.0.0: 0.0.0.0:* LISTEN /rpc.statd
tcp6 ::: :::* LISTEN -
tcp6 ::: :::* LISTEN /rpc.statd
tcp6 ::: :::* LISTEN -
tcp6 ::: :::* LISTEN /rpcbind
tcp6 ::: :::* LISTEN /rpc.mountd
tcp6 ::: :::* LISTEN /httpd
tcp6 ::: :::* LISTEN -
tcp6 ::: :::* LISTEN /rsync
tcp6 ::: :::* LISTEN /sshd
tcp6 ::: :::* LISTEN /cupsd
2>如果是普通文件
lsof
fuser
3>如果是磁盘空间
du -sh : 查看当前目录总共占的容量。而不单独列出各子项占用的容量
du -lh --max-depth=1 : 查看当前目录下一级子文件和子目录占用的磁盘容量
4> 如何释放缓存
用sync命令可以把内存中的数据写入硬盘,同时还有/proc/sys/vm/drop_caches这个文件可以。
关于drop_caches文件:系统默认为0, 在Documentation/sysctl/vm.txt中有如下描述:
drop_caches
Writing to this will cause the kernel to drop clean caches, dentries and inodes from memory, causing that memory to become free.
To free pagecache:仅清除页面缓存(PageCache)
echo 1 > /proc/sys/vm/drop_caches
To free dentries and inodes:清除目录项和inode
echo 2 > /proc/sys/vm/drop_caches
To free pagecache, dentries and inodes:清除页面缓存,目录项和inode
echo 3 > /proc/sys/vm/drop_caches
As this is a non-destructive operation and dirty objects are not freeable, the user should run `sync' first.
一般来讲 echo 1 > /proc/sys/vm/drop_caches就好。
linux查看文件被哪个进程占用?的更多相关文章
- Linux 查看文件被那个进程写数据
目录 背景 步骤 获取写文件的进程号 文件被那个进程使用,写数据不是用lsof可以找出来吗,但现实情况是lsof没找出来T_T 背景 centos7 在某一段时间监控报警磁盘使用率达99%,由于监控属 ...
- lsof 查看文件被哪个进程占用
lsof 是什么意思? 答: list open files 查看某个文件被哪些进程在读写 lsof 文件名 查看某个进程打开了哪些文件lsof –c 进程名lsof –p 进程号 lsof用法小全 ...
- windows 查看文件被哪个进程占用
经常当我们删除文件时,有时会提示[操作无法完成,因为文件已在另一个程序中打开,请关闭该文件并重试],到底是哪些程序呢? 有时候一个一个找真不是办法,已经被这个问题折磨很久了,今天下决心要把它解决,找到 ...
- Windows 有没有办法查看文件被哪个进程占用
经常当我们删除文件时,有时会提示[操作无法完成,因为文件已在另一个程序中打开,请关闭该文件并重试],到底是哪些程序呢? 有时候一个一个找真不是办法,已经被这个问题折磨很久了,今天下决心要把它解决,找到 ...
- linux查看端口被那个进程占用
linux下遇到端口被暂用了 需要知道是哪个进程 比如80端口 可以这样 netstat -tunlp|
- Linux查看端口被哪个进程占用
netstat -lnp|awk 'BEGIN{prt=":443$"}{if ($4 ~ prt) print $0}' 查看443端口
- linux如何查看端口被哪个进程占用的方法
linux如何查看端口被哪个进程占用的方法: 1.lsof -i:端口号2.netstat -tunlp|grep 端口号 都可以查看指定端口被哪个进程占用的情况[步骤一]lsof -ilsof -i ...
- Windows下查找文件或文件夹被哪个进程占用
Linux下我们可以使用lsof +D /filepath/,查看到文件被那些进程占用. windows下也会经常遇到文件夹或文件无法删除或无法访问的问题,使用“资源监视器”可以找到占用的进程,可以尝 ...
- Win和Linux查看端口和杀死进程
title: Win和Linux查看端口和杀死进程 date: 2017-7-30 tags: null categories: Linux --- 本文介绍Windows和Linux下查看端口和杀死 ...
随机推荐
- array_column 低版本兼容
function i_array_column($input, $columnKey, $indexKey=null){ if(!function_exists('array_column')){ $ ...
- cmd从新获取ip
1.ipconfig/release 2.ipconfig/renew
- java基本数据间转换
string=====>int int x = Integer.parseInt(“1111”); string=====>char char x = request.getParamet ...
- sed常见用法总结
编辑文本 sed -i '1i xyz' test.txt 在第一行之前 sed -i '1a xyz' test.txt 在第一行之后插入 sed -i '1c xyz' test.txt 把第一行 ...
- dbcp第一次获取连接的时间问题
最近优化代码,发现第一次调用数据库连接时非常慢,往后便不再发生.经了解,数据库连接是用dbcp管理的,想在网上查找答案,但没有找到.在某人的提醒下决定研究源代码: 部分源代码如下(BasicDataS ...
- jenkins搭建自动化部署平台(svn+tomcat重启)
原文链接:http://blog.csdn.net/zjs40/article/details/51818322 jenkins 自动化部署和集成代码的平台 可以将Git svn 上的代码 check ...
- CentOS ./configure && make && make install详解
码的安装一般由3个步骤组成:配置(configure).编译(make).安装(make install). 在Linux中利用源码包安装软件最重要的就是要仔细阅读安装包当中的README INST ...
- LibreOJ 6282. 数列分块入门 6
题目链接:https://loj.ac/problem/6282 参考博客:http://www.cnblogs.com/stxy-ferryman/p/8560551.html 这里如果用数组的话元 ...
- axaj 的回调
//为了动态生成表格获取数据用ajax获取servlet回调数据 <script> $.ajax({ url = "servlet地址", type : "p ...
- 179. Largest Number(INT, String)
Given a list of non negative integers, arrange them such that they form the largest number. For exam ...