如何在Linux中linux查看进程命令所有正在运行的进程

Linux&怎样知道某个进程在哪个CPU上运行
ps命令的输出格式可以通过-o参数定制,可以使用如下命令显示进程所对应的执行CPU:
# ps -eo pid,args,psr
参数的含义:
pid - 进程ID
args - 该进程执行时传入的命令行参数
psr - 分配给进程的CPU
有关ps命令的其它信息请查阅ps手册:
[root@www ~]# ps -eo pid,args,psr
.............
20965 /usr/local/php-fcgi/bin/php&
21683 /bin/sh /usr/local/ddos/ddo&
21684 sleep 600&
21746 /sbin/udevd -d&
21832 /bin/sh /usr/local/ddos/ddo&
21833 sleep 600&
21865 sshd: root@pts/0&
21873 -bash& &&
21927 ps -eo pid,args,psr&
23520 [pdflush]&
23744 nginx: master process /usr/&
23745 nginx: worker process&
23749 nginx: worker process&
23753 nginx: worker process&
23755 nginx: worker process&
已投稿到:
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。Linux中如何查找或删除正在使用某文件的进程?
Linux中如何查找或删除正在使用某文件的进程?
我们可以使用fuser命令,示例如下:
fuser filename
fuser -k filename
fuser命令是用来显示所有正在使用着指定的file, file system 或者 sockets的进程信息。
fuser的其他有用的参数
-a Show all files specified on the command line. By default, only files that are accessed by at least one
process are shown.
-c Same as -m option, used for POSIX compatibility.
-f Silently ignored, used for POSIX compatibility.
-k Kill processes accessing the file. Unless changed with -signal, SIGKILL is sent. An fuser process never
kills itself, but may kill other fuser processes. The effective user ID of the process executing fuser
is set to its real user ID before attempting to kill.
-i Ask the user for confirmation before killing a process. This option is silently ignored if -k is not
present too.
-l List all known signal names.
-m name specifies a file on a mounted file system or a block device that is mounted. All processes access-
ing files on that file system are listed. If a directory file is specified, it is automatically changed
to name/. to use any file system that might be mounted on that directory.
Select a different name space. The name spaces file (file names, the default), udp (local UDP ports),
and tcp (local TCP ports) are supported. For ports, either the port number or the symbolic name can be
specified. If there is no ambiguity, the shortcut notation name/Ispace (e.g. 80/tcp ) can be used.
-s Silent operation. -u and -v are ignored in this mode. -a must not be used with -s.
Use the specified signal instead of SIGKILL when killing processes. Signals can be specified either by
name (e.g. -HUP) or by number (e.g. -1). This option is silently ignored if the -k option is not used.
-u Append the user name of the process owner to each PID.
-v Verbose mode. Processes are shown in a ps-like style. The fields PID, USER and COMMAND are similar to
ps. ACCESS shows how the process accesses the file. If the access is by the kernel (e.g. in the case of
a mount point, a swap file, etc.), kernel is shown instead of the PID.
-V Display version information.
-4 Search only for IPv4 sockets. This option must not be used with the -6 option and only has an effect
with the tcp and udp namespaces.
-6 Search only for IPv6 sockets. This option must not be used with the -4 option and only has an effect
with the tcp and udp namespaces.
- Reset all options and set the signal back to SIGKILL.
#fuser &m &u /mnt/usb1
/mnt/usb1: 1347c(root) 1348c(guido) 1349c(guido)
在例子一中,使用了-m和-u选项,用来查找所有正在使用/mnt/usb1的所有进程的PID已经该进程的OWNER,如1347c(root),其中1347是进程PID,root是该进程的OWNER。
fuser会显示正在使用指定的file,file system 或者 sockets的进程的PID。在默认的显示模式下,每个文件名之后会跟随一个字符,用来指示当前的访问类型。
如下所示:
current directory.
executable being run.
open file.
open file for writing.
root directory.
mmap'ed file or shared library
同时fuser 可以用来查找哪些进程正在使用指定的network port。
[root@bl25p-19 /]# fuser -v -n tcp 111
USER PID ACCESS COMMAND
111/tcp: rpc 2848 F.... portmap
fuser 的返回值:
fuser如果没有找到任何进程正在使用指定的file, filesystem 或 socket, 或者在查找过程中发生了fatal error,则返回non-zero 值。
fuser如果找到至少一个进程正在使用指定的file, filesystem 或 socket,则返回zero。
fuser 常用场景
fuser通常被用在诊断系统的&resource busy&问题,通常是在你希望umount指定的挂载点得时候遇到。 如果你希望kill所有正在使用某一指定的file, file system or sockets的进程的时候,你可以使用-k option。
fuser &k /path/to/your/filename
这时fuser会向所以正在使用/path/to/your/filename的进程发送SIGKILL。如果你希望在发送之前得到提示,可以使用-i 选项。
fuser &k &i /path/to/your/filename
其他类似的新闻
● ● ● ● ● ● ● ● ● ●
其他相关的新闻
获取更多淘宝免单秒杀活动加QQ群:
最新热点新闻
小伙伴最爱的新闻
小伙伴还关注了以下信息
小伙伴关注的焦点
小伙伴都在关注的热门词
Copyright (C) 2006- Inc. All Rights Reserved
孝感风信信息技术有限公司 ● 版权所有如何在Linux中查看所有正在运行的进程_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
如何在Linux中查看所有正在运行的进程
上传于||暂无简介
阅读已结束,如果下载本文需要使用
想免费下载本文?
下载文档到电脑,查找使用更方便
还剩1页未读,继续阅读
你可能喜欢

我要回帖

更多关于 linux 查看进程端口 的文章

 

随机推荐