免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1373 | 回复: 3
打印 上一主题 下一主题

[系统管理] %PPID是作用 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2015-08-18 14:26 |只看该作者 |倒序浏览

export pid=$(/sbin/pidof -o %PPID -x sh30)


论坛徽章:
33
ChinaUnix元老
日期:2015-02-02 08:55:39CU十四周年纪念徽章
日期:2019-08-20 08:30:3720周年集字徽章-周	
日期:2020-10-28 14:13:3020周年集字徽章-20	
日期:2020-10-28 14:04:3019周年集字徽章-CU
日期:2019-09-08 23:26:2519周年集字徽章-19
日期:2019-08-27 13:31:262016科比退役纪念章
日期:2022-04-24 14:33:24
2 [报告]
发表于 2015-08-18 14:38 |只看该作者
-o     Tells pidof to omit processes with that process id. The special pid %PPID can be used to name the parent process of the pidof program, in other words the calling shell or shell script.

论坛徽章:
0
3 [报告]
发表于 2015-08-18 15:37 |只看该作者
谢谢

-x     Scripts too - this causes the program to also return process id's of shells running the
              named scripts.
我的理解是返回此脚本的PID, 但我一下的例子没能成功显示此脚本的PID号。

[root@oranode2 xxx]# cat test3.sh
#!/bin/bash
pid=$(/sbin/pidof -x vi)
echo $pid

[root@oranode2 xxx]# ./test3.sh     
23345 22946


[root@oranode2 xxx]# ps -ef | grep vi
root     22946 22069  0 14:18 pts/1    00:00:00 vi functions.sh
root     23345 21927  0 15:24 pts/0    00:00:00 vi test
root     23405 22602  0 15:34 pts/2    00:00:00 grep --color=auto vi

论坛徽章:
7
2015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:57:092015小元宵徽章
日期:2015-03-06 15:58:18程序设计版块每日发帖之星
日期:2015-08-09 06:20:00每日论坛发贴之星
日期:2015-08-09 06:20:00程序设计版块每日发帖之星
日期:2015-08-22 06:20:00程序设计版块每日发帖之星
日期:2015-08-27 06:20:00
4 [报告]
发表于 2015-08-18 17:17 |只看该作者
这是啥命令,学习学习。。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP