WebMasterCampus
WEB DEVELOPER Resources

Linux nohup Command

Learn Linux nohup Command with examples


Linux nohup Command

In Linux, we can use “nohup” command that runs the process even after logging out from the shell/terminal.

Nohup, short for no hang up is a command in Linux systems that keep processes running even after exiting the shell or terminal.

nohup Command Syntax

>> nohup command [command-argument ...]

nohup –version

The version of nohup command can be checked by using the following command.

>> nohup --version

Starting a process using Nohup

If you want to keep your processes/jobs running, precede the command with nohup as shown below.

The jobs will still continue running in the shell and will not get killed upon exiting the shell or terminal.

>> nohup ./log_clean_up.sh

Additionally, you can opt to redirect the output to a different file.

>> nohup ./log_clean_up.sh > output.txt

To redirect to a file and to standard error and output use the > filename 2>&1 attribute.

>> nohup ./hello.sh > myoutput.txt >2&1

Starting a process in the background using Nohup

To start a process in the background use the & symbol at the end of the command.

In this example, we are pinging google.com and sending it to the background.

>> nohup ping bing.com &

To run the command in the background , append the & symbol at the end of the command.

If for some reason you want to terminate the process, use the kill command followed by the process ID.

>> kill -9 23142
Created with love and passion.