屏蔽標準輸出流/dev/null exec

/dev/null:

可定義標準輸出流,一般可用來實現屏蔽指定進程終端上的標準輸出信息:

exec /mnt/platform/bin/test > /dev/null &

--------------------------------------------------------------

exec 命令:使用exec來調用腳本,被執行的腳本會繼承當前shell的環境變量。但事實上exec產生了新的進程,他會把主shell的進程資源佔用並替換腳本內容,繼承了原主shell的PID號,即原主shell剩下的內容不會執行。

但是在實際測試過程中所有的程序均正常運行,test1 test2 test3都在運行,不是很理解!

#!/bin/bash
VALUE=1
if [ $VALUE -eq 1 ]; then
echo "before the exec function!"
exec /home/cristl/mywork/example/test/exec/test1 > /dev/null &
exec /home/cristl/mywork/example/test/exec/test2 &
exec /home/cristl/mywork/example/test/exec/test3 &
echo "after the exec function!"
fi
這裏做個備註,後面找到原因繼續跟進。

.......

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章