Many system administrators make a practice of using GNU Screen or tmux to manage jobs running in the terminal. If you have a long-running job that you want to "detach" from the terminal, you can simply use your terminal multiplexer to do it. But what if you don't use tmux or Screen, or you just forgot? For those times, there's nohup and disown.

Have a long-running job you want to "detach" from the terminal? Don't use tmux or Screen? If you haven't started the job yet, nohup is an easy to use option, and if you must stop a job in the middle, there's disown.

If you haven't started the job yet, there's nohup. Short for "no hangup," nohup will detach the program from the current shell and send its output to nohup.out. If you quit the shell or whatever, the process will continue to run until it completes.

Ah, but what if you forget to use nohup, or if you didn't expect to be leaving the computer but get called away? Then there's disown.

The use of disown is a bit more complex. While the command is running, use Ctrl-z to stop it and then use bg to put it in the background. Then you'll use disown %n where n is the job number (jobspec). And, of course, you can find the job number using the jobs command. Run jobs again to verify that the job has been detached -- and you can use ps or top to verify that the job is actually still running.

nohup和disown的更多相关文章

  1. Linux 将进程放入后台执行,解决网络,ssh断开导致进程结束(nohup, setsid, &, disown)

    Linux 将进程放入后台执行,解决网络,ssh断开导致进程结束(nohup,  setsid,  &, disown) 1.nohup 命令 我们知道,当用户注销(logout)或者网络断开 ...

  2. Linux运行与控制后台进程的方法:nohup, setsid, &, disown, screen

    我们经常会碰到这样的问题,用ssh登录了远程的Linux服务器,运行了一些耗时较长的任务,结果却由于网络等的不稳定导致任务中途失败.这是由于在用户注销(logout)或者网络断开时,终端会收到 HUP ...

  3. 让进程在后台可靠运行的几种方法 nohup,setsid,&,disown,CTRL-z ,screen

    让进程在后台可靠运行的几种方法 几年前在developerWorks上面看到的文章,感觉非常实用,又简单整理了一下,转到这里,希望给看到的人带来一些帮助.文中提到的nohup和subshell方式一直 ...

  4. Linux 系统命令

    1.ctrl+z 让正在运行的任务暂停运行, 然后可用 bg %jobId使之后台运行,相当于: 命令 & 2. jobs -l 查看任务 3. echo $$ 查看当前进程 4.nohup ...

  5. Linux基础精华

    Linux基础精华 (继续跟新中...) 常用命令: Linux shell 环境 让你提升命令行效 率的 Bash 快捷键 [完整版] 设置你自己的liux alias Linux的Find使用 L ...

  6. jenkins2 pipeline介绍

    文章来自:http://www.ciandcd.com 文中的代码来自可以从github下载: https://github.com/ciandcd   什么是jenkins2的pipeline?   ...

  7. linux上的常见命令掌握

    http://coolshell.cn/articles/8883.html 这篇文章来源于Quroa的一个问答<What are some time-saving tips that ever ...

  8. 最有用的Linux命令行使用技巧集锦

    最近在Quora上看到一个问答题目,关于在高效率Linux用户节省时间Tips.将该题目的回答进行学习总结,加上自己的一些经验,记录如下,方便自己和大家参考. 下面介绍的都是一些命令行工具,这些工具在 ...

  9. 高效Linux用户需要了解的命令行技能

    最近在Quora上看到一个问答题目,关于在高效率Linux用户节省时间Tips. 将该题目的回答进行学习总结,加上自己的一些经验,记录如下,方便自己和大家参考. 下面介绍的都是一些命令行工具,这些工具 ...

随机推荐

  1. splay好板子

    找到一份比较好的板子,链接https://blog.csdn.net/crazy_ac/article/details/8034190 #include<cstdio> #include& ...

  2. 【C++】类前置声明范例

    • 在编写C++程序的时候,偶尔需要用到前置声明(Forward declaration).下面的程序中,带注释的那行就是类B的前置说明.这是必须的,因为类A中用到了类B,而类B的声明出现在类A的后面 ...

  3. hdu 1027 输出第m个全排列(next_permutation)

    Sample Input6 4 //输出第4个全排列11 8 Sample Output1 2 3 5 6 41 2 3 4 5 6 7 9 8 11 10 # include <cstdio& ...

  4. Android开发之实现多次点击事件

    在Android中给我们提供了单次点击事件.但并没有给我们提供双击,或者实现在一定时间内的多次事件.所以需要我们自己在单机监听上进行修改实现. 有如下两种实现方式: 1.定义一个存贮上一个第一次点击的 ...

  5. mysql替换字符串

    今天要替换数据库里的所有字符串 例如把http改成https UPDATE table_name set colum_name=REPLACE(colum_name,'http','https')

  6. 「2017 山东一轮集训 Day7」逆序对

    题解: 满满的套路题.. 首先显然从大到小枚举 然后每次生成的逆序对是1----(i-1)的 这样做dp是nk的 复杂度太高了 那我们转化一下问题 变成sigma(ai   (ai<i)  )= ...

  7. EXIST子查询

    已知关系模式:S(Sno,Sname,Sclass),C(Cno,Cname,Cteacher),SC(Sno,Cno,Scgrade).其中,S为学生关系:Sno学号, Sname姓名,Sclass ...

  8. AndrodStudio报错: Cannot launch AVD in emulator.

    Cannot launch AVD in emulator.Output:Hax is enabledHax ram_size 0x60000000HAX is working and emulato ...

  9. Unity 中几点注意的地方

    1.面板摆放的规范 2.project工程面板中 文件夹命名的规范,不同类型的东西要分类摆放,例如Script 3.不要留空函数体(系统自动生成Start, Uadate等),空函数体一样会执行,尤其 ...

  10. FastAdmin 的上传代码在哪里?

    FastAdmin 的上传代码在哪里? FastAdmin 默认是通过 Ajax 上传到本地. 使用 admin/ajax/upload 方式返回 url. 代码文件地址在 application\a ...