Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the use of Linux's nohup command

Shulou Source: shulou.com Published: 2022-06-01 18:32:20 10月02日 Update

This article mainly introduces the relevant knowledge of the use of Linux's nohup command, the content is detailed and easy to understand, the operation is simple and fast, and has a certain reference value. I believe you will gain something after reading this Linux nohup command. Let's take a look at it.

Linux commonly used command nohup English full name no hang up (do not hang up), used in the system background without hanging up to run the command, exit the terminal will not affect the operation of the program.

Syntax format nohup Command [Arg... ] [&] Parameter description: Command: command to be executed.

Arg: some parameters, you can specify the output file.

&: let the command execute in the background, and the command will still be executed after the terminal exits.

For example, the following command executes the runoob.sh script in the root directory in the background:

Nohup / root/runoob.sh-if you see the following output on the terminal, the operation is successful:

Appending output to nohup.out when we open the root directory, we can see that the nohup.out file is generated.

If you want to stop running, you need to find the nohup run script to PID using the following command, and then use the kill command to delete it:

Ps-aux | grep "runoob.sh" parameter description:

A: show all programs

U: display in a user-based format

X: show all programs, regardless of terminal

You can also use the ps-def | grep "runoob.sh" command to find it.

Once the PID is found, you can use kill PID to delete it.

Kill-9 process number PID the following command executes the runoob.sh script in the root directory in the background and redirects the input to the runoob.log file:

Nohup / root/runoob.sh > runoob.log 2 > & 1 & 2 > & 1 explanation:

Standard error 2 is redirected to standard output & 1, and standard output & 1 is then redirected into the runoob.log file.

0-stdin (standard input, standard input)

1-stdout (standard output, standard output)

2-stderr (standard error, standard error output)

This is the end of the article on "what is the use of Linux's nohup command". Thank you for reading! I believe you all have a certain understanding of the knowledge of "what is the use of Linux's nohup command". If you want to learn more, you are welcome to follow the industry information channel.

Tags: Command standard output run background file terminal parameter directory knowledge program script input content format article error success value full name Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology MySQL Shulou Information Huawei MariaDB