linux怎么查看服务是否运行?

2025-01-06 17:45:54
推荐回答(3个)
回答1:

1、ps
aux
或netstat
-tlunp
ps是进程查看命令,netstat是端口查看命令,在linux系统中,服务一定是有进程的,所以使用ps命令可以查看服务运行情况,另外,linux服务多数是网络服务,所以通过netstat命令也可以查看服务运行状态。
2、service
服务名
status
比如查看httpd的web服务的运行状态,执行service
httpd
status,如下图所示:
3、/sbin/service
--status-all
|grep
"服务名"
比如查看httpd的web服务,执行
/sbin/service
--status-all
|grep
"httpd"即可。如下图所示。
4、chkconfig
--list
比如查看httpd的web服务,执行
chkconfig
--list
|grep
"httpd"即可。如下图所示。

回答2:

服务运行都会对应的产生相应的进程, 建议你用这条命令 ps -ef | grep -v “grep” 有结果代表 服务是运行的

回答3:

'ps -ef' is standard syntax;
'ps -aux' is BSD syntax.
They are all the sames to display the process status.
eg:

test 7291 0.0 0.0 103332 928 pts/0 S+ 15:39 0:00 grep 123.py
test is user of OS;
7291 is the process ID;
0.0/0.0 are usages of CPU and Memory;
103332 means number of Virtual Set Size;
928 means number of Resident Set Size;
pts/0 means TTY device;
S+ means the process is sleeping.
15:39 means starting time;
0:00 means running time;
'grep 123.py' is the processing name.
test 7291 0.0 0.0 103332 928 pts/0 S+ 15:39 0:00 grep 123.py
test 7291 0.0 0.0 103332 928 pts/0 S+ 15:39 0:00 123.py
There is two processes. they are all run in your process, but now, it may be sleep or terminated.
I suggest you use command 'man ps' to get more help in linux.