pgrep 多个进程名称

pgrep multiple process names

我想在 Linux 中使用 "pgrep" 命令获取两个或更多进程的 PID。

我们知道 pgrep 语法是

pgrep [options] <pattern>

这是一个假设的命令,它应该 return 两个进程的 PID,其名称分别为 process1process2

pgrep process1 OR process2 

实现上述需要使用什么模式?

尝试:

pgrep 'process1|process2'

示例:

 -->pgrep 'atd|cron'
1078
1093

 -->ps -eaf |grep -E 'atd|cron'
daemon    1078     1  0 Aug08 ?        00:00:00 /usr/sbin/atd -f
root      1093     1  0 Aug08 ?        00:00:19 /usr/sbin/cron -f
xxxx  14364  9597  0 11:56 pts/2    00:00:00 grep -E atd|cron