黄色片网站免费观看-黄色片网站观看-黄色片网站大全-黄色片视频网-色偷偷网址-色偷偷网站

disown

從當(dāng)前的shell中移除作業(yè)。

概要

disown [-h] [-ar] [jobspec ... | pid ...]

主要用途

選項(xiàng)

-h    標(biāo)記每個(gè)作業(yè)標(biāo)識(shí)符,這些作業(yè)將不會(huì)在shell接收到sighup信號(hào)時(shí)接收到sighup信號(hào)。
-a    移除所有的作業(yè)。
-r    移除運(yùn)行的作業(yè)。

參數(shù)

jobspec(可選):要移除的作業(yè)標(biāo)識(shí)符,可以是一到多個(gè)。

pid(可選):要移除的作業(yè)對(duì)應(yīng)的進(jìn)程ID,可以是一到多個(gè)。

返回值

返回成功除非未開(kāi)啟作業(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è),并沒(méi)有停止。
[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è),并沒(méi)有停止。
[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è),并沒(méi)有停止。
[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)在打開(kāi)新終端查找該作業(yè)。
[user2@pc] pgrep -a -u user2 -f 'sleep 90'
109080 sleep 90

注意

  1. bash的作業(yè)控制命令包括bg fg kill wait disown suspend
  2. 該命令需要set選項(xiàng)monitor處于開(kāi)啟狀態(tài)時(shí)才能執(zhí)行;查看作業(yè)控制狀態(tài):輸入set -o查看monitor行;執(zhí)行set -o monitorset -m開(kāi)啟該選項(xiàng)。
  3. 該命令是bash內(nèi)建命令,相關(guān)的幫助信息請(qǐng)查看help命令。

參考鏈接