叉状指挥燮preSS通知被杀 [英] Suppress Notice of Forked Command Being Killed
本文介绍了叉状指挥燮preSS通知被杀的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
让我们假设我有一个bash脚本( foo.sh
),在一个非常简单的形式,如下所示:
Let's suppose I have a bash script (foo.sh
) that in a very simplified form, looks like the following:
echo "hello"
sleep 100 &
ps ax | grep sleep | grep -v grep | awk '{ print $1 } ' | xargs kill -9
echo "bye"
第三行模仿 pkill的
,我不默认情况下,在Mac OS X有,但你可以把它当做一样 pkill的
。然而,当我运行此脚本,我得到以下的输出:
The third line imitates pkill
, which I don't have by default on Mac OS X, but you can think of it as the same as pkill
. However, when I run this script, I get the following output:
hello
foo: line 4: 54851 Killed sleep 100
bye
我如何燮preSS中间的线,让所有我看到的是你好
和再见
?
推荐答案
如何不认?这主要适用于我的击在Linux上。
How about disown? This mostly works for me on Bash on Linux.
echo "hello"
sleep 100 &
disown
ps ax | grep sleep | grep -v grep | awk '{ print $1 } ' | xargs kill -9
echo "bye"
编辑:匹配海报的code更好
Matched the poster's code better.
这篇关于叉状指挥燮preSS通知被杀的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文