disown Command Examples

本文详细介绍了如何在Linux Shell环境中使用disown命令删除当前bash/ksh或POSIX shell中的作业,包括删除所有作业、仅删除运行中的作业以及保留运行中作业在退出终端时不被终止的方法。

I am a new Linux and Unix shell user. How do I Remove or delete jobs from current bash / ksh or POSIX based shell?

Job control is nothing but the ability to stop/suspend the execution of processes (command) and continue/resume their execution as per your requirements. This is done using your operating system and shell such as bash/ksh or POSIX shell.

disown command details 
DescriptionRemove jobs from
current shell
CategoryProcesses Management
DifficultyEasy
Root privilegesNo
Estimated completion time5m
Contents
You need to use bg command to restart a stopped background process. The fg command moves a background job in the current shell environment into the foreground. To delete/remove jobs or to tell the shell not to send a HUP signal use disown command. This command is part of bash or ksh93 shell.

Purpose

Remove jobs from the table of active job.

Syntax

The basic syntax is as follows:

disown jobID

OR

disown jobID1 jobID2 ... jobIDN

OR

disown [options] jobID1 jobID2 ... jobIDN

A note about BASH and KSH93 disown command
=> The disown command on ksh shell causes the shell not to send a HUP signal to each given job, or all active jobs if job is omitted, when a login shell terminates.
=>The disown command on bash shell can either remove jobs or causes the shell not to send a HUP signal to each given job or all jobs.
=> All examples, on this page are executed on bash shell either on OS X Unix or Ubuntu Linux.

disown command examples

Before you start using fg command, you need to start couple of jobs on your system for demonstration purpose. Type the following commands to start jobs:

xeyes &
gnome-calculator &
gedit fetch-stock-prices.py &

Finally, run ping command in foreground:

ping cyberciti.biz

To suspend ping command job hit the Ctrl-Z key sequence. Use the jobs -l command to list current jobs:
$ jobs -l
Without any options, each jobID is removed from the table of active jobs i.e. the bash shell uses its notion of the current job which is displayed by + symbol in jobs -l command:
$ disown
Sample outputs:

Fig. 01: disown command in action

Fig. 01: disown command in action

How do I remove all jobs?

Pass the -a option to disown command, type:
$ disown -a
## You should not see any jobs running on screen ##
$ jobs -l

How do I remove only running jobs?

Pass the -r option to disown command, type:
$ disown -r
$ jobs -l

How do I keep running job after I exit from a shell prompt in background?

The SIGHUP (Hangup) signal is used by your system on controlling terminal or death of controlling process. You can use SIGHUP to reload configuration files and open/close log files too. In other words if you logout from your terminal all running jobs will be terminated. To avoid this you can pass the -h option to disown command. This option mark each jobID so that SIGHUP is not sent to the job if the shell receives a SIGHUP. The syntax is:
$ disown -h jobID
disown -h %2

In this example, update the Debian or Ubuntu Linux based server using apt-get command in background:

## Step 1: update system ##
apt-get upgrade &> /root/system.update.log &
 
## Step 2: Mark apt-get so that SIGHUP is not sent when you exit and go for tea ##
disown -h
 
## Step 3: exit from root shell ##
exit
 

Please note that you can also use nohup command to set the signal SIGHUP to be ignored for any command on Linux or Unix for same purpose.

disown command options

From the bash(1) command man page:

OptionDescription
-aDelete all jobs if jobID is not supplied.
-hMark each jobID so that SIGHUP is not sent to the job if the shell receives a SIGHUP.
-rDelete only running jobs.

Related media

This tutorial is also available in a quick video format:


http://www.cyberciti.biz/faq/unix-linux-disown-command-examples-usage-syntax/

内容概要:本文提出了一种基于融合鱼鹰算法和柯西变异的改进麻雀优化算法(OCSSA),用于优化变分模态分解(VMD)的参数,进而结合卷积神经网络(CNN)与双向长短期记忆网络(BiLSTM)构建OCSSA-VMD-CNN-BILSTM模型,实现对轴承故障的高【轴承故障诊断】基于融合鱼鹰和柯西变异的麻雀优化算法OCSSA-VMD-CNN-BILSTM轴承诊断研究【西储大学数据】(Matlab代码实现)精度诊断。研究采用西储大学公开的轴承故障数据集进行实验验证,通过优化VMD的模态数和惩罚因子,有效提升了信号分解的准确性与稳定性,随后利用CNN提取故障特征,BiLSTM捕捉时间序列的深层依赖关系,最终实现故障类型的智能识别。该方法在提升故障诊断精度与鲁棒性方面表现出优越性能。; 适合人群:具备一定信号处理、机器学习基础,从事机械故障诊断、智能运维、工业大数据分析等相关领域的研究生、科研人员及工程技术人员。; 使用场景及目标:①解决传统VMD参数依赖人工经验选取的问题,实现参数自适应优化;②提升复杂工况下滚动轴承早期故障的识别准确率;③为智能制造与预测性维护提供可靠的技术支持。; 阅读建议:建议读者结合Matlab代码实现过程,深入理解OCSSA优化机制、VMD信号分解流程以及CNN-BiLSTM网络架构的设计逻辑,重点关注参数优化与故障分类的联动关系,并可通过更换数据集进一步验证模型泛化能力。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值