![Forrest logo](/images/logo.png)
nohup
nohup is a command line tool in Unix-like operating systems that allows you to run a command that will continue running even if the terminal session ends. The name "nohup" stands for "no hang-up" and it prevents the process from being terminated when the terminal is closed.
When you execute a command using nohup, it redirects all the output to a file named nohup.out by default. This file captures both standard output and standard error messages, which can be useful for debugging and monitoring the progress of long-running processes.
Using nohup is particularly beneficial when running commands that take a significant amount of time to complete and you don't want the process to be interrupted if you log out or the terminal crashes.
One common usage of nohup is when running commands over SSH. With nohup, you can initiate a long-running task on a remote server and safely disconnect from the SSH session without terminating the command. You can then reconnect later to check the status or retrieve the output.
nohup can be combined with other shell commands or scripts for complex operations. It is often used alongside the "&" symbol, which executes the command in the background. This allows running multiple processes concurrently without blocking the terminal.
To stop a process that was started with nohup, you can find its process ID (PID) using the "ps" command and then terminate it using the "kill" command.
In addition to redirecting output to nohup.out, you can specify a custom file for output redirection using the ">" operator. This allows you to store the output in a specific file or append to an existing file.
nohup is a reliable tool for long-running tasks and ensures that your commands continue running even after you disconnect from the terminal or the system encounters an error.
The basic syntax of using nohup is: "nohup command [arguments] &".
Overall, nohup is a powerful command line utility that gives you control and persistence over long-running processes by preventing them from being terminated when you log out or the terminal session ends.
List of commands for nohup:
-
nohup:tldr:407c7 nohup: Launch `nohup` in background mode.$ nohup ${command} ${argument1 argument2 ---} &try on your machineexplain this command
-
nohup:tldr:44966 nohup: Run a process that can live beyond the terminal.$ nohup ${command} ${argument1 argument2 ---}try on your machineexplain this command
-
nohup:tldr:49a0f nohup: Run a process and write the output to a specific file.$ nohup ${command} ${argument1 argument2 ---} > ${path-to-output_file} &try on your machineexplain this command
-
nohup:tldr:60e71 nohup: Run a shell script that can live beyond the terminal.$ nohup ${path-to-script-sh} &try on your machineexplain this command