Developer(s) | Various open-source and commercial developers |
---|---|
Operating system | Unix, Unix-like, IBM i |
Platform | Cross-platform |
Type | Command |
nohup is a POSIX command which means "no hang up". Its purpose is to execute a command such that it ignores the HUP (hangup) signal and therefore does not stop when the user logs out.
Output that would normally go to the terminal goes to a file called nohup.out, if it has not already been redirected.
The first of the commands below starts the program abcd
in the background in such a way that the subsequent logout does not stop it.
$ nohup abcd &$ exit
Note that these methods prevent the process from being sent a 'stop' signal on logout, but if input/output is being received for these standard I/O files (stdin, stdout, or stderr), they will still hang the terminal. [1] See Overcoming hanging, below.
nohup is often used in combination with the nice command to run processes on a lower priority.
$ nohup nice abcd &
Some shells (e.g. bash) provide a shell builtin that may be used to prevent SIGHUP being sent or propagated to existing jobs, even if they were not started with nohup. In bash, this can be obtained by using disown -h job
; using the same builtin without arguments removes the job from the job table, which also implies that the job will not receive the signal. Before using disown
on an active job, it should be stopped by Ctrl-Z
, and continued in the background by the bg
command. [2] Another relevant bash option is shopt huponexit
, which automatically sends the HUP signal to jobs when the shell is exiting normally. [3]
The AIX and Solaris versions of nohup have a -p
option that modifies a running process to ignore future SIGHUP signals. Unlike the above-described disown
builtin of bash, nohup -p
accepts process IDs. [4]
The nohup command has also been ported to the IBM i operating system. [5]
Note that nohupping backgrounded jobs is typically used to avoid terminating them when logging off from a remote SSH session. A different issue that often arises in this situation is that ssh is refusing to log off ("hangs"), since it refuses to lose any data from/to the background job(s). [6] [7] This problem can also be overcome by redirecting all three I/O streams:
$ nohup ./myprogram > foo.out 2> foo.err < /dev/null &
Also note that a closing SSH session does not always send a HUP signal to dependent processes, such as when a pseudo-terminal has not been allocated. [8]
$ screen -A -m -d -S somename ./somescript.sh &
A background process is a computer process that runs behind the scenes and without user intervention. Typical tasks for these processes include logging, system monitoring, scheduling, and user notification. The background process usually is a child process created by a control process for processing a computing task. After creation, the child process will run on its own, performing the task independent of the control process, freeing the control process of performing that task.
In computing, a fork bomb is a denial-of-service attack wherein a process continually replicates itself to deplete available system resources, slowing down or crashing the system due to resource starvation.
In multitasking computer operating systems, a daemon is a computer program that runs as a background process, rather than being under the direct control of an interactive user. Traditionally, the process names of a daemon end with the letter d, for clarification that the process is in fact a daemon, and for differentiation between a daemon and a normal computer program. For example, syslogd is a daemon that implements system logging facility, and sshd is a daemon that serves incoming SSH connections.
In computing, time
is a command in Unix and Unix-like operating systems. It is used to determine the duration of execution of a particular command.
GNU Screen is a terminal multiplexer, a software application that can be used to multiplex several virtual consoles, allowing a user to access multiple separate login sessions inside a single terminal window, or detach and reattach sessions from a terminal. It is useful for dealing with multiple programs from a command line interface, and for separating programs from the session of the Unix shell that started the program, particularly so a remote process continues running even when the user is disconnected.
In computing, echo
is a command that outputs the strings that are passed to it as arguments. It is a command available in various operating system shells and typically used in shell scripts and batch files to output status text to the screen or a computer file, or as a source part of a pipeline.
An orphan process is a computer process whose parent process has finished or terminated, though it remains running itself.
In computing, kill
is a command that is used in several popular operating systems to send signals to running processes.
On POSIX-compliant platforms, SIGHUP is a signal sent to a process when its controlling terminal is closed. It was originally designed to notify the process of a serial line drop. SIGHUP is a symbolic constant defined in the header file signal.h
.
A command shell is a command-line interface to interact with and manipulate a computer's operating system.
fish is a Unix shell with a focus on interactivity and usability. Fish is designed to give the user features by default, rather than by configuration. Fish is considered an exotic shell since it does not rigorously adhere to POSIX shell standards, at the discretion of the maintainers.
GNOME Terminal is a terminal emulator for the GNOME desktop environment written by Havoc Pennington and others. Terminal emulators allow users to access a UNIX shell while remaining on their graphical desktop.
In computing, sleep is a command in Unix, Unix-like and other operating systems that suspends program execution for a specified time.
In computing, a shell builtin is a command or a function, called from a shell, that is executed directly in the shell itself, instead of an external executable program which the shell would load and execute.
In Unix shells, wait
is a command which pauses until execution of a background process has ended.
In Unix and Unix-like operating systems, job control refers to control of jobs by a shell, especially interactively, where a "job" is a shell's representation for a process group. Basic job control features are the suspending, resuming, or terminating of all processes in the job/process group; more advanced features can be performed by sending signals to the job. Job control is of particular interest in Unix due to its multiprocessing, and should be distinguished from job control generally, which is frequently applied to sequential execution.
In a Unix shell, the full stop called the dot command (.) is a command that evaluates commands in a computer file in the current execution context. In C Shell, a similar functionality is provided as the source
command, and this name is seen in "extended" POSIX shells as well.
The restricted shell is a Unix shell that restricts some of the capabilities available to an interactive user session, or to a shell script, running within it. It is intended to provide an additional layer of security, but is insufficient to allow execution of entirely untrusted software. A restricted mode operation is found in the original Bourne shell and its later counterpart Bash, and in the KornShell. In some cases a restricted shell is used in conjunction with a chroot jail, in a further attempt to limit access to the system as a whole.
In the Unix shells ksh, bash, fish and zsh, the disown builtin command is used to remove jobs from the job table, or to mark jobs so that a SIGHUP signal is not sent to them if the parent shell receives it.
Shellshock, also known as Bashdoor, is a family of security bugs in the Unix Bash shell, the first of which was disclosed on 24 September 2014. Shellshock could enable an attacker to cause Bash to execute arbitrary commands and gain unauthorized access to many Internet-facing services, such as web servers, that use Bash to process requests.
{{cite web}}
: CS1 maint: url-status (link)