Linux命令之pidof

本文介绍如何使用pidof和killall5命令来查找并管理正在运行的进程,包括获取进程ID、发送信号及批量终止进程的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

pidof - 找出正在运行程序的进程PID

程序可以是一个二进制执行程序,

也可以是一个shell脚本。

如果是找出java程序的进程PID,pidof就无能为力了,可以使用ps -ef|grep java或jps -l来查看java进程的信息。

通常找出进程PID的目的是确认程序是否在运行、或者为了把它杀掉、或者发送一个信号给它。


参数:
-s 表示只返回1个 pid
-x 表示同时返回运行给定程序的 shell 的 pid
-o 表示告诉 piod 表示忽略后面给定的 pid ,可以使用多个 -o 。

-----------------------------------------------------------------------我是分割线-----------------------------------------------------------------

--killall5 -- send a signal to all processes.

killall5 -signalnumber [-o omitpid] [-o omitpid..]

Description

killall5 is the SystemV killall command. It sends a signal to all processes exceptkernel threads and the processes in its own session, so it won't kill the shell that is running the script it was called from. Its primary (only) use is in therc scripts found in the /etc/init.d directory.

Notes

killall5 can also be invoked as pidof, which is simply a (symbolic) link to thekillall5 program.

Exit Status

The program return zero if it killed processes.

It return 2 if no process were killed,

and 1 ifit was unable to find any processes (/proc/ is missing).


---------------------------------------我是分割线------------------------------------------------------


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值