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 ...
随机推荐
- java_reflect_04
反射操作数组: 通过public Class<?> getComponentType()来取得一个数组的Class对象 例: import java.lang.reflect.Array ...
- 将CSS CLIP属性应用在:扩展覆盖效果
我们想要展示如何利用CSS3 clip属性制作一种简单而整洁的扩展效果,当点击一个box元素时实现平稳过渡.这个想法是为了实现某种叠加效果,好像它实际上在各个元素的下面.点击其中一个元素将创建一个切断 ...
- js学习笔记之:数组(二)
今天来学习一下数组的遍历.删除等知识点: 1 数组的遍历 数组元素的遍历可以使用for循环,采用关键字for...in var aCity = new Array("北京" ...
- oracle创建表空间、用户、用户授权、删除表空间、删除用户
--创建临时表空间 create temporary tablespace test_temp --test_temp表空间名称 tempfile 'E:\oracle\product\10.2.0\ ...
- 感性体验 Android 5.0 Lollipop
引言 Android5.0大概是在11月下旬开始进行OTA推送,博主手上的这台五太子(Nexus 5)也在前几天收到了Google的推送,博主当然是按耐不住赶紧FQ升级啦,但无奈的是这个大版本更新包有 ...
- linux c信息验证程序(分享)
程序来源是Hirst First c,程序很简单,但却是很好的说明了一个检测信息是否被串改的原理.下载程序的时候是否都有看到提供md5效验值的呢,原理其实和这个小程序相似:就是对程序的内容进行某种计算 ...
- 实验三:gdb跟踪调试内核从start_kernel到init进程启动
原创作品转载请注明出处<Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-1000029000 如果我写的不好或者有误的地方请留言 ...
- SpringMVC入门2-注解开发
Spring MVC 注解开发 <context:component-scan base-package="com.controls" /> Springmvc的扫描器 ...
- Fireworks Extension —— AutoSlice 介绍
前不久在网上到处瞎晃的时候,发现Adobe的软件几乎都可以写插件.Fireworks更是很早的版本就支持使用javascript编写插件,于是乎如入桃园,奋斗几日为VD小伙伴们写了一个插件,命名Aut ...
- Qt Quick分组属性案例
import QtQuick 2.4 import QtQuick.Controls 1.4 import QtQuick.Controls.Styles 1.4 import QtQuick.Win ...