W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
從當(dāng)前的shell中移除作業(yè)。
disown [-h] [-ar] [jobspec ... | pid ...]
-h 標(biāo)記每個(gè)作業(yè)標(biāo)識(shí)符,這些作業(yè)將不會(huì)在shell接收到sighup信號(hào)時(shí)接收到sighup信號(hào)。
-a 移除所有的作業(yè)。
-r 移除運(yùn)行的作業(yè)。
jobspec(可選):要移除的作業(yè)標(biāo)識(shí)符,可以是一到多個(gè)。
pid(可選):要移除的作業(yè)對(duì)應(yīng)的進(jìn)程ID,可以是一到多個(gè)。
返回成功除非未開啟作業(yè)控制或執(zhí)行出現(xiàn)錯(cuò)誤。
# 演示。
[user2@pc] ssh 192.168.1.4
user2@192.168.1.4's password:
# 此時(shí)按下ctrl+z使得交互停止。
[1]+ Stopped ssh 192.168.1.4
[user2@pc] ssh 192.168.1.7
user2@192.168.1.7's password:
# 此時(shí)按下ctrl+z使得交互停止。
[1]+ Stopped ssh 192.168.1.7
[user2@pc] sleep 120 &
[3] 28986
# 列出作業(yè)及pid信息。
[user2@pc] jobs -l
[1]- 28756 Stopped ssh 192.168.1.4
[2]+ 28833 Stopped ssh 192.168.1.7
[3] 28986 Running sleep 120 &
# 刪除運(yùn)行狀態(tài)的作業(yè)。
[user2@pc] disown -r
[user2@pc] jobs -l
[1]- 28756 Stopped ssh 192.168.1.4
[2]+ 28833 Stopped ssh 192.168.1.7
# 注意disown只是移除作業(yè),并沒有停止。
[user2@pc] pgrep -a -u user2 -f 'sleep 120'
28986 sleep 120
# 刪除指定的作業(yè)。
[user2@pc] disown %2
bash: warning: deleting stopped job 2 with process group 28833
[user2@pc] jobs -l
[1]- 28756 Stopped ssh 192.168.1.4
# 注意disown只是移除作業(yè),并沒有停止。
[user2@pc] pgrep -a -u user2 -f 'ssh 192.168.1.7'
28833 ssh 192.168.1.7
# 刪除全部作業(yè)。
[user2@pc] disown -a
bash: warning: deleting stopped job 1 with process group 28756
[user2@pc] jobs -l
# 注意disown只是移除作業(yè),并沒有停止。
[user2@pc] pgrep -a -u user2 -f 'ssh 192.168.1.4'
28756 ssh 192.168.1.4
# 演示-h選項(xiàng)的作用。
[user2@pc] sleep 90 &
[1] 109080
[user2@pc] jobs -l
[1]+ 109080 Running sleep 90 &
[user2@pc] disown -h %1
[user2@pc] exit
# 此時(shí)前一個(gè)終端已經(jīng)關(guān)閉,現(xiàn)在打開新終端查找該作業(yè)。
[user2@pc] pgrep -a -u user2 -f 'sleep 90'
109080 sleep 90
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: