Get the App
SLTechnology News&Howtos  ›  Servers  › 

What is the principle of nohup and its actual combat analysis

Shulou Source: shulou.com Published: 2022-06-01 02:36:58 10月01日 Update

This article shows you what the nohup principle is and the actual combat analysis. The content is concise and easy to understand. It will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

This paper mainly introduces the principle of Linux nohup command and example parsing, which is introduced in detail through the example code, which has a certain reference value for everyone's study or work.

Nohup command

When applying Unix/Linux, we usually want a program to run in the background, so we will often use & at the end of the program to let the program run automatically. For example, we want to run mysql in the background: / usr/local/mysql/bin/mysqld_safe-user=mysql &. But there are a lot of programs that are not like mysqld, so we need nohup commands.

Process and job management

The nohup command can run the program in a way that ignores the suspend signal, and the output information of the program being run will not be displayed to the terminal.

Whether or not the output of the nohup command is redirected to the terminal, the output is appended to the nohup.out file in the current directory. If the nohup.out file in the current directory is not writable, the output is redirected to the $HOME/nohup.out file. If there is no file that can be created or opened for append, the command specified by the command parameter cannot be called. If standard error is a terminal, the specified command is written to all outputs of standard error as standard output is redirected to the same file descriptor.

Grammar

Nohup (option) (parameter)

Option

-- help: online help-- version: display version information

Parameters.

Programs and options: programs and options to run

Example

one

Run the jar package of spring boot, and the Spring Boot project is still running in the background when the current terminal is closed

Nohup java-jar springboot.jar &

two

Use the nohup command to submit a job, and if you use the nohup command to submit a job, all output from that job is redirected by default to a file named nohup.out, unless another output file is specified:

Nohup command > myout.file 2 > & 1 &

In the above example, the output is redirected to the myout.file file

The above content is what the nohup principle is and the actual combat analysis. Have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Tags: Commands outputs files programs runs terminals jobs principles parameters background standards actual combat actual combat analysis analysis information content examples skills directories knowledge Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Linux Redmi Huawei Apple