如何屏蔽杀输出 [英] How to shield the kill output
本文介绍了如何屏蔽杀输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我喜欢运行的脚本:
sleep 20 &
PID=$!
kill -9 $PID >/dev/null 2>&1
我不希望脚本显示类似的输出:
I dont want the script show the output like:
line 51: 22943 Killed sleep
我不知道为什么发生这种情况,我将输出重定向到/ dev / null的
I have no idea why this happen, I have redirect the output to /dev/null
推荐答案
该消息不会从未来无论是杀
或背景命令,它是从庆典时,它的到来发现其后台的工作之一,已被杀害。为了避免消息,使用不认
从庆典的作业控制其删除:
The message isn't coming from either kill
or the background command, it's coming from bash when it discovers that one of its background jobs has been killed. To avoid the message, use disown
to remove it from bash's job control:
sleep 20 &
PID=$!
disown $PID
kill -9 $PID
这篇关于如何屏蔽杀输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文