linux nohup命令
nohup 命令
用途:不挂断地运行命令。如果你正在执行一个job,并且你希望在退出帐户/关闭终端之后继续运行,可以使用nohup命令。nohup就是不挂起的意思( no hang up)。
语法:nohup Command [ Arg … ] [ & ]
描述:nohup 命令运行由 Command 参数和任何相关的 Arg 参数指定的命令,忽略所有挂断(SIGHUP)信号。在注销后使用 nohup 命令运行后台中的程序。要运行后台中的 nohup 命令,添加 & ( 表示”and”的符号)到命令的尾部。
无论是否将 nohup 命令的输出重定向到终端,输出都将附加到当前目录的 nohup.out 文件中。如果当前目录的 nohup.out 文件不可写,输出重定向到 $HOME/nohup.out 文件中。如果没有文件能创建或打开以用于追加,那么 Command 参数指定的命令不可调用。如果标准错误是一个终端,那么把指定的命令写给标准错误的所有输出作为标准输出重定向到相同的文件描述符。
=======测试
[root@rhel7 tmp]# pwd
/tmp
[root@rhel7 tmp]# ls
[root@rhel7 tmp]# nohup ping 127.0.0.1 &
[]
[root@rhel7 tmp]# nohup: ignoring input and appending output to ‘nohup.out’ [root@rhel7 tmp]# ls
nohup.out
[root@rhel7 tmp]# tail -f nohup.out --关闭当前连接,重新再打开一个ssh连接,使用tail -f nohup.out命令可以看到ping命令一直在执行
bytes from 127.0.0.1: icmp_seq= ttl= time=0.077 ms
bytes from 127.0.0.1: icmp_seq= ttl= time=0.044 ms
bytes from 127.0.0.1: icmp_seq= ttl= time=0.129 ms
bytes from 127.0.0.1: icmp_seq= ttl= time=0.084 ms
bytes from 127.0.0.1: icmp_seq= ttl= time=0.085 ms
bytes from 127.0.0.1: icmp_seq= ttl= time=0.085 ms
bytes from 127.0.0.1: icmp_seq= ttl= time=0.079 ms
bytes from 127.0.0.1: icmp_seq= ttl= time=0.078 ms
bytes from 127.0.0.1: icmp_seq= ttl= time=0.078 ms
bytes from 127.0.0.1: icmp_seq= ttl= time=0.083 ms
bytes from 127.0.0.1: icmp_seq= ttl= time=0.043 ms
bytes from 127.0.0.1: icmp_seq= ttl= time=0.084 ms
^C
[root@rhel7 tmp]#
指定输出到lxjtest.log。如果不指定,则输出到nohup.out文件
[root@rhel7 tmp]# nohup ping 127.0.0.1 >lxjtest.log &
[]
[root@rhel7 tmp]# nohup: ignoring input and redirecting stderr to stdout [root@rhel7 tmp]# ls
lxjtest.log nohup.out
[root@rhel7 tmp]# tail -f lxjtest.log
PING 127.0.0.1 (127.0.0.1) () bytes of data.
bytes from 127.0.0.1: icmp_seq= ttl= time=0.039 ms
bytes from 127.0.0.1: icmp_seq= ttl= time=0.073 ms
bytes from 127.0.0.1: icmp_seq= ttl= time=0.043 ms
bytes from 127.0.0.1: icmp_seq= ttl= time=0.043 ms
bytes from 127.0.0.1: icmp_seq= ttl= time=0.044 ms
bytes from 127.0.0.1: icmp_seq= ttl= time=0.044 ms
bytes from 127.0.0.1: icmp_seq= ttl= time=0.043 ms
bytes from 127.0.0.1: icmp_seq= ttl= time=0.079 ms
bytes from 127.0.0.1: icmp_seq= ttl= time=0.079 ms
bytes from 127.0.0.1: icmp_seq= ttl= time=0.086 ms
^C
[root@rhel7 tmp]#
In earlier versions of the bash shell, background processes were also killed when the shell they were started from was terminated. To prevent that, the process could be started with the nohup command in front of it. Using nohup for this purpose is no longer needed in RHEL 7. (RHEL7版本可以不使用nohup命令)
[root@rhel7 tmp]# ping 192.168.1.111 > lxjtest2.log &
[]
[root@rhel7 tmp]# jobs
[]+ Running ping 192.168.1.111 > lxjtest2.log &
[root@rhel7 tmp]#
linux nohup命令的更多相关文章
- Linux nohup 命令
Linux nohup 命令 如果你正在运行一个进程,而且你觉得在退出帐户时该进程还不会结束,那么可以使用nohup命令.该命令可以在你退出帐户之后继续运行相应的进程.nohup就是不挂起的意思(no ...
- linux–nohup命令(转)
在应用Unix/Linux时,我们一般想让某个程序在后台运行,于是我们将常会用 & 在程序结尾来让程序自动运行.比如我们要运行mysql在后台: /usr/local/mysql/bin/my ...
- LINUX nohup命令输入输出深浅进出
无论是否将 nohup命令的输出重定向到终端,输出都将附加到当前目录的 nohup.out 文件中.如果当前目录的 nohup.out 文件不可写,输出重定向到 $HOME/nohup.out 文件中 ...
- Linux nohup命令详解
nohup命令及其输出文件 ...
- linux nohup命令实现退出终端后程序继续后台运行
Unix/Linux下一般想让某个程序在后台运行,很多都是使用&在程序结尾来让程序自动运行:但如果要想在退出终端后,程序依然还在后台运行,则要用nohup与&组合来实现. nohup ...
- Linux nohup命令应用简介--让Linux的进程不受终端影响
nohup命令应用简介--让Linux的进程不受终端影响 by:授客 QQ:1033553122 #开启ping进程 [root@localhost ~]# ping localhost & ...
- linux nohup命令使程序在后台运行的方法
在linux操作系统中从后台一直运行某个程序的方法,就是使用nohup命令了. Unix/Linux下一般比如想让某个程序在后台运行,很多都是使用 & 在程序结尾来让程序自动运行. 比如要运行 ...
- Linux nohup命令详解,终端关闭程序依然可以在执行!
大家好,我是良许. 在工作中,我们很经常跑一个很重要的程序,有时候这个程序需要跑好几个小时,甚至需要几天,这个时候如果我们退出终端,或者网络不好连接中断,那么程序就会被中止.而这个情况肯定不是我们想看 ...
- Linux Shell nohup命令用法
linux的nohup命令的用法. 在应用Unix/Linux时,我们一般想让某个程序在后台运行,于是我们将常会用 & 在程序结尾来让程序自动运行.比如我们要运行mysql在后台: /us ...
随机推荐
- RB1001: IE6 IE7 IE8(Q) 负边距 (margin) 导致元素溢出 hasLayout 容器时显示异常
标准参考 根据W3C CSS2.1规范第8.3节中的描述,边距属性设置了一个框的边距区的宽度.'margin' 缩写属性设置所有四边的边距,而其它的边距属性( 'margin-top' ,'margi ...
- RedHat9上安装jdk
1.先在windows下载jdk:jdk-6-dlj-linux-i586.bin 2.用ftp上传给linux下 3.chmod 777 jdk-6-dlj-linux-i586.bin 4.将jd ...
- javescript扩展方法
<script type="text/javascript"> //扩展方法 '原型'->'prototype' //通过类对像的prototype设置扩展方法 ...
- Yii2的相关学习记录,自定义gii模板和引用vendor中的js、css(四)
上文中后台模板框架已经搭建起来了,但还是有些不协调,像是有两个User标题,或者我们想自己在gii生成时添加或删除些公用的东西.这就需要我们定义自己的gii模板. 我们以CRUD的模板为例,默认的gi ...
- 9个最新的手机/移动设备jQuery插件
随着互联网的流行,移动网站开始急速增加,在2014年手机网站将会出现很多,所以手机网站是必须要学会制作的.手机网站不像桌面平台一样制作,否则会影响显示效果,目前大部分手机网站使用响应式设计技术,而且也 ...
- PHP面向对象(OOP)编程完全教程:10.__set(),__get(),__isset(),__unset()四个方法的应用
一般来说,总是把类的属性定义为private,这更符合现实的逻辑.但是, 对属性的读取和赋值操作是非常频繁的,因此在PHP5中,预定义了两个函数”__get()”和”__set()”来获取和赋值其属性 ...
- 「30天自制操作系统」 Stop & 「OS67 」 Start
废话 整个十月都没有再写一点什么, 其实没什么好写的, 把书里的东西码出来贴在博客里实在没什么意思, 况且书里已经写得够详细了. 这本书给我最深刻的感觉是, 作者通过简化一些细节, 一步一步地模拟整个 ...
- Unity脚本获取内存和FPS
using System; using System.Collections.Generic; using UnityEngine; public class Debugger : MonoBehav ...
- 如何修正Feedly文章中文標題亂碼或無法正常顯示的問題
在7月1日Google關閉Reader之前,我想應該有許多人都已經從Google Reader移到其他服務上了,其中受益最大的者莫過於Feedly了,一下子就吸收了幾百萬的用戶,而我也是其中之一,由於 ...
- java代码调用rtx发送提醒消息
http://www.cnblogs.com/qstar/archive/2012/02/03/Astar.html 借用一下!好东西