linux查看程序运行状态linux查看程序运行

如题所述

在linux下怎么查找一个正在运行的进程‘?

ps-ef|grep进程名ps-ef:查看正在运行的进程|:管道命令,将前者的输出作为后者的输入grep进程名:在输入数据中查找进程信息

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

可以在Linux下输入命令:

1、$servicesshdstatus2、#serviceservicenamestatus是当前状态3、#chkconfig--listservicename是查看启动状态,也就是是否开机自动启动注:

1、如果service和chkconfig找不到,可以试试/sbin/service和/sbin/chkconfig2、如果用ubuntu好像是要用/etc/init.d/servicenamestatus查看当前状态(servicename就是你要查的服务名)扩展资料:查看某项服务当前启动状态的其他方式一、利用进程来查看命令里ps-aux|grepxxx是查看某个进程或者服务是否存在。

二、利用services命令1、查看单个服务的运行状态:service服务名status如:#servicesshdstatusopenssh-daemon(pid3701)正在运行

2、查看所有服务的运行状态:service_status-all

linux怎么查看一个进程的执行状态?

1,写一个服务,用exec或popen执行ps的命令行,根据该进程的名字获取该进程的pid。

sprintf(cmd,"ps-ef|grep%s",name);

pstr=popen(cmd,"r");

然后php定时的请求这个机器上的进程状态,如果进程挂掉了,可以做个预警。

2,如果想做的更多,监视当前每个进程的资源消耗,比如CPU,内存,根据进程的id,可以去拿到/proc/pid/status中的一些数据,比如:

//获取进程占用内存

unsignedintget_proc_mem(unsignedintpid){

charfile_name={0};

FILE*fd;

charline_buff={0};

sprintf(file_name,"/proc/%d/status",pid);

fd=fopen(file_name,"r");

if(nullptr==fd){

return0;

}

charname;

intvmrss;

for(inti=0;iVMRSS_LINE-1;i++){

fgets(line_buff,sizeof(line_buff),fd);

}

fgets(line_buff,sizeof(line_buff),fd);

sscanf(line_buff,"%s%d",name,vmrss);

fclose(fd);

returnvmrss;

}

然后你就可以通过一些图形做一些动态展示了。

linux中如何查看软件开启状态?

可以在Linux下输入命令:

1、$servicesshdstatus

2、#serviceservicenamestatus是当前状态

3、#chkconfig--listservicename是查看启动状态,也就是是否开机自动启动

linux如何查看程序的运行参数?

如果是现在运行的程序你可以使用:psaux|grep程序名如果系统自带的命令,直接看man手册就很方便manls

温馨提示:答案为网友推荐,仅供参考