Home  >  Article  >  Detailed explanation of nohup command

Detailed explanation of nohup command

小老鼠
小老鼠Original
2023-10-25 16:20:454172browse

nohup is a commonly used command in Unix and Unix-like systems. It is used to run commands in the background and redirect the output of the command to a file. It will continue to run even after the user logs out or the terminal is closed. . Detailed explanation and usage of the nohup command: "nohup command [parameters] [input file] [output file]", where the command is the command to be run in the background, the parameters are the options and parameters of the command, and the input file is the input file of the command , the output file is the output file of the command.

Detailed explanation of nohup command

nohup is a command commonly used in Unix and Unix-like systems. It is used to run commands in the background and redirect the output of the command to a file. Keeps running even after the user logs out or the terminal is closed. The following is a detailed explanation and usage of the nohup command:

nohup 命令 [参数] [输入文件] [输出文件]

Among them, the command is the command to be run in the background, the parameters are the options and parameters of the command, the input file is the input file of the command, and the output file is the output of the command document.

Usage example:

  1. Run the command in the background and redirect the output to a file:

    nohup command > output.log &

    Run the command command in the background and redirect the output to a file. Its output is redirected to the output.log file. The & symbol means running the command in the background.

  2. Run the command in the background and redirect the output and error information to the file:

    nohup command > output.log 2>&1 &

    Run the command command in the background and redirect its output and error information All are redirected to the output.log file.

  3. Specify the input file:

    nohup command < input.txt > output.log &

    Run the command command in the background, use the input.txt file as the input file of the command, and redirect the output to output.log in the file.

  4. Ignore the SIGHUP signal:

    nohup -i command > output.log &

    Use the -i parameter to ignore the SIGHUP signal, that is, no signal to terminate the command will be sent when the user logs out.

It should be noted that the nohup command will run the command in the background, but it will not make the command a daemon process. If you need to create a daemon process, you can use the nohup command with the & symbol, and use some specific options and parameters in the command.

This is the basic explanation and usage example of the nohup command. In actual use, you can choose the appropriate options and parameters as needed. You can view more detailed help information through the nohup --help command.

The above is the detailed content of Detailed explanation of nohup command. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:How to create a soft linkNext article:How to create a soft link