linux系统中pgrep用于查找进程
1、查找与命令相关的进程
[root@centos79 test]# pgrep sort
[root@centos79 test]#
启动一个sort命令测试:
[root@centos79 test]# seq -f test%03g 100000000| sort | uniq -c [root@centos79 test]# pgrep sort ## 另外一个终端 18521 [root@centos79 test]# pgrep -l sort ## -l 列出具体命令 18521 sort
2、-u查找与用户相关的进程
[root@centos79 test]# pgrep -u root | head 1 2 4 6 7 8 9 10 11 12
[root@centos79 test]# pgrep -l -u root | head 1 systemd 2 kthreadd 4 kworker/0:0H 6 ksoftirqd/0 7 migration/0 8 rcu_bh 9 rcu_sched 10 lru-add-drain 11 watchdog/0 12 watchdog/1
3、-l ,-u + 命令关键字 查找与用户指定命令相关的进制
[root@centos79 test]# pgrep -l -u root | tail 18314 kworker/0:0 18328 kworker/1:5 18329 kworker/1:6 18421 kworker/3:1 18489 kworker/3:0 18491 kworker/u256:2 18502 kworker/0:2 18568 kworker/0:1 18577 sleep 18584 tail
利用root启动一个sort命令:
[root@centos79 test]# pgrep -l -u root sort
在另一个终端测试查找:
[root@centos79 test]# pgrep -l -u root sort 18612 sort
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。