在sh脚本,得到一个后台进程的PID [英] in a sh script, get the pid of a background process

查看:531
本文介绍了在sh脚本,得到一个后台进程的PID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能知道iwevent过程在以下bash脚本的PID:

Is it possible to know the pid of the iwevent process in the following bash script:

#!/bin/sh
( iwevent | logger -t IWEVENT ) &
echo the pid is: ???

注意iwevent运行到CTRL-C信号。

Note that iwevent run until ctrl-c signal.

仅供参考。
我在的/ etc /网络/接口向上语句运行此脚本,我要杀死正在运行的进程iwevent在相关的向下的语句。我的目的是要登录无线事件。

FYI. I run this script in a /etc/network/interfaces "up" statement and I want to kill the running iwevent process in the related "down" statement. My aim is to log wireless events.

推荐答案

检查的pidof功能搜索
看到这个 http://en.wikipedia.org/wiki/Pidof 结果
并检查手册页:男人的pidof

check "pidof" function
see this http://en.wikipedia.org/wiki/Pidof
and check the man page: man pidof

这篇关于在sh脚本,得到一个后台进程的PID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆