Nohup command
Purpose: To run the command without hanging off. If you are executing a job and you want to continue running after exiting the account/shutting down the terminal, you can use the Nohup command. Nohup is the meaning of not hanging (no hang up).
Syntax: Nohup Command [Arg ...] [&]
Description: The nohup command runs commands specified by the command parameter and any related ARG parameters, ignoring all hang-up (SIGHUP) signals. Use the Nohup command to run a program in the background after logging off. To run the Nohup command in the background, add & (the symbol representing "and") to the end of the command.
The output is appended to the Nohup.out file in the current directory, regardless of whether the output of the Nohup command is redirected to the terminal. If the nohup.out file for the current directory is not writable, the output is redirected to the $HOME/nohup.out file. If no file can be created or opened for appending, then the command specified by the commands parameter is not callable. If the standard error is a terminal, then all output of the specified command to the standard error is redirected to the same file descriptor as the standard output.
======= Test
[email protected] tmp]# pwd/Tmp[[email protected] tmp]# ls[[email protected] tmp]# nohup Ping127.0.0.1& [1]2547[email protected] tmp]# nohup:ignoring input and appending output to ' nohup. out' [[email protected] tmp]# lsnohup. out[email protected] tmp]# tail-F Nohup. out--Close the current connection, re-open an SSH connection, and use the tail-f nohup.out command to see that the ping command has been executing -bytes from 127.0.0.1: icmp_seq= +Ttl= -Time=0.077Ms -bytes from 127.0.0.1: icmp_seq= ATtl= -Time=0.044Ms -bytes from 127.0.0.1: icmp_seq= atTtl= -Time=0.129Ms -bytes from 127.0.0.1: icmp_seq= -Ttl= -Time=0.084Ms -bytes from 127.0.0.1: icmp_seq= -Ttl= -Time=0.085Ms -bytes from 127.0.0.1: icmp_seq= -Ttl= -Time=0.085Ms -bytes from 127.0.0.1: icmp_seq= -Ttl= -Time=0.079Ms -bytes from 127.0.0.1: icmp_seq= -Ttl= -Time=0.078Ms -bytes from 127.0.0.1: icmp_seq= inTtl= -Time=0.078Ms -bytes from 127.0.0.1: icmp_seq= -Ttl= -Time=0.083Ms -bytes from 127.0.0.1: icmp_seq= toTtl= -Time=0.043Ms -bytes from 127.0.0.1: icmp_seq= +Ttl= -Time=0.084Ms^C[[email protected] tmp]#
Specifies the output to Lxjtest.log. If not specified, output to the Nohup.out file
[[email protected] tmp]# nohup Ping127.0.0.1>lxjtest.log & [1]2641[[email protected] tmp]# nohup:ignoring input and redirecting stderr to Stdout[[email protected] tmp]# Lslxjtest.log Nohup. out[email protected] tmp]# tail-F lxjtest.log PING127.0.0.1(127.0.0.1) About( -) bytes of data. -bytes from 127.0.0.1: icmp_seq=1Ttl= -Time=0.039Ms -bytes from 127.0.0.1: icmp_seq=2Ttl= -Time=0.073Ms -bytes from 127.0.0.1: icmp_seq=3Ttl= -Time=0.043Ms -bytes from 127.0.0.1: icmp_seq=4Ttl= -Time=0.043Ms -bytes from 127.0.0.1: icmp_seq=5Ttl= -Time=0.044Ms -bytes from 127.0.0.1: icmp_seq=6Ttl= -Time=0.044Ms -bytes from 127.0.0.1: icmp_seq=7Ttl= -Time=0.043Ms -bytes from 127.0.0.1: icmp_seq=8Ttl= -Time=0.079Ms -bytes from 127.0.0.1: icmp_seq=9Ttl= -Time=0.079Ms -bytes from 127.0.0.1: icmp_seq=TenTtl= -Time=0.086Ms^C[[email protected] tmp]#
In earlier versions of the Bash shell, background processes were also killed when the shell they were started from is TER Minated. To prevent that, the process could is started with the nohup command in front of it. using Nohup for this purpose are no longer needed in RHEL 7. (RHEL7 version can not use Nohup command)
192.168. 1.111 > Lxjtest2.log &[12649[[email protected] tmp]# jobs[1 ]+ Running 192.168. 1.111 > Lxjtest2.log &
Linux nohup commands