https://blog.csdn.net/lzufeng/article/details/83537275
linux或mac控制台下输入ps -ef | grep 关键字可以查看是否有相应的进程启动信息中包含关键字。如:
ps的意思是process status,即进程状态。在控制台执行man ps命令可以查看ps命令后面的命令选项的含义如下:
The options are as follows:
-A Display information about other users' processes, including those without controlling ter- minals.
-a Display information about other users' processes as well as your own. This will skip any processes which do not have a controlling terminal, unless the -x option is also specified.
-C Change the way the CPU percentage is calculated by using a ``raw'' CPU calculation that ignores ``resident'' time (this normally has no effect).
-c Change the ``command'' column output to just contain the executable name, rather than the full command line.
-d Like -A, but excludes session leaders.
-E Display the environment as well. This does not reflect changes in the environment after process launch.
-e Identical to -A.
-f Display the uid, pid, parent pid, recent CPU usage, process start time, controlling tty, elapsed CPU usage, and the associated command. If the -u option is also used, display the user name rather then the numeric uid. When -o or -O is used to add to the display follow- ing -f, the command field is not truncated as severely as it is in other formats. -G Display information about processes which are running with the specified real group IDs.
-g Display information about processes with the specified process group leaders.
-h Repeat the information header as often as necessary to guarantee one header per page of information.
-j Print information associated with the following keywords: user, pid, ppid, pgid, sess, jobc, state, tt, time, and command.
-L List the set of keywords available for the -O and -o options.
-l Display information associated with the following keywords: uid, pid, ppid, flags, cpu, pri, nice, vsz=SZ, rss, wchan, state=S, paddr=ADDR, tty, time, and command=CMD.
-M Print the threads corresponding to each task.
-m Sort by memory usage, instead of the combination of controlling terminal and process ID.
-O Add the information associated with the space or comma separated list of keywords speci- fied, after the process ID, in the default information display. Keywords may be appended with an equals (`=') sign and a string. This causes the printed header to use the speci- fied string instead of the standard header. -o Display information associated with the space or comma separated list of keywords speci- fied. Multiple keywords may also be given in the form of more than one -o option. Key- words may be appended with an equals (`=') sign and a string. This causes the printed header to use the specified string instead of the standard header. If all keywords have empty header texts, no header line is written.
-p Display information about processes which match the specified process IDs.
-r Sort by current CPU usage, instead of the combination of controlling terminal and process ID.
-S Change the way the process time is calculated by summing all exited children to their par- ent process.
-T Display information about processes attached to the device associated with the standard input.
-t Display information about processes attached to the specified terminal devices.
-U Display the processes belonging to the specified real user IDs.
-u Display the processes belonging to the specified usernames.
-v Display information associated with the following keywords: pid, state, time, sl, re, pagein, vsz, rss, lim, tsiz, %cpu, %mem, and command. The -v option implies the -m option.
-w Use 132 columns to display information, instead of the default which is your window size. If the -w option is specified more than once, ps will use as many columns as necessary without regard for your window size. When output is not to a terminal, an unlimited number of columns are always used. -X When displaying processes matched by other options, skip any processes which do not have a controlling terminal.
-x When displaying processes matched by other options, include processes which do not have a controlling terminal. This is the opposite of the -X option. If both -X and -x are speci- fied in the same command, then ps will use the one which was specified last. 可见 -e和-A的意思是一样的,即显示有关其他用户进程的信息,包括那些没有控制终端的进程。 -f显示用户id,进程id,父进程id,最近CPU使用情况,进程开始时间等等。 --------------------- 作者:要努力活得更好 来源: 原文:https://blog.csdn.net/lzufeng/article/details/83537275 版权声明:本文为博主原创文章,转载请附上博文链接!
PS是LINUX下最常用的也是非常强大的进程查看命令 //以下这条命令是检查java 进程是否存在. ps -ef |grep java 下面对命令选项进行说明: -e 显示所有进程。 -f 全格式。 ps e 列出程序时,显示每个程序所使用的环境变量。 ps f 用ASCII字符显示树状结构,表达程序间的相互关系 grep命令是一种强大的文本搜索工具,它能使用正则表达式搜索文本,并把匹 配的行打印出来。grep全称是Global Regular
Expression Print,表示全局正则表达式版本,它的使用权限是所有用户。 ps -ef | grep httpd : 检查httpd进程是否存在 ps -ef | grep httpd :检查httpd进程的命令!
ps用于查看当前进行,ps -ef用于查看当前所有的进程。 其他常用参数如下: 1.ps a 显示现行终端机下的所有程序,包括其他用户的程序。 2.ps -A 显示所有程序。 3.ps c 列出程序时,显示每个程序真正的指令名称,而不包含路径,参数或常驻服务的标示。 4.ps -e 此参数的效果和指定"A"参数相同。 5.ps e 列出程序时,显示每个程序所使用的环境变量。 6.ps f 用ASCII字符显示树状结构,表达程序间的相互关系。 7.ps -H 显示树状结构,表示程序间的相互关系。 8.ps -N 显示所有的程序,除了执行ps指令终端机下的程序之外。 9.ps s 采用程序信号的格式显示程序状况。 10.ps S 列出程序时,包括已中断的子程序资料。 11.ps -t<终端机编号> 12.ps u 13.ps x