In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to use the nohup command of Linux". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn how to use the nohup command of Linux.
The nohup command can run the program in a way that ignores the hang signal, and the output information of the program being run will not be displayed to the terminal.
Command
Purpose: run the command without hanging up. Syntax: nohup Command [Arg... [&] description: the nohup command runs the command specified by the Command parameter and any related Arg parameters, ignoring all SIGHUP signals. Use the nohup command to run the program in the background after logging out. To run the nohup command in the background, add & (the symbol for "and") to the end of the command.
Nohup is the abbreviation of no hang up, which means don't hang up.
Nohup command: if you are running a process and you don't think it will end when you exit your account, you can use the nohup command. This command can continue to run the corresponding process after you exit your account / close the terminal.
By default, all output from the job is redirected to a file called nohup.out.
There are three common streams in the operating system:
0: standard input stream stdin
1: standard output stream stdout
2: standard error stream stderr
Generally, when we use > console.txt, it is actually the ellipsis of 1 > console.txt.
Example nohup. / command > myout.file 2 > & 1 &
In the above example, 0-stdin (standard input), 1-stdout (standard output), 2-stderr (standard error)
2 > & 1 redirects the standard error (2) to the standard output (& 1), which is then redirected to the myout.file file.
Nohup. / command.sh > / dev/null 2 > & 1 &
The function of / dev/null file, this is a bottomless pit, anything can be directed here, but can not be opened. So generally large stdou and stderr can be directed here using stdout and stderr when you don't care.
The difference between nohup and &
&: it runs in the background, but when the user launches (suspends), the command automatically exits.
Nohup: do not hang up to run, note that there is no function to run in the background, that is, running a command with nohup can make the command execute permanently and has nothing to do with the user terminal. For example, if we disconnect the SSH, it will not affect his operation. Note that nohup does not mean to run in the background; & it is running in the background.
So, we can skillfully combine them to be nohup COMMAND & so that the command can be executed permanently in the background.
For example:
Sh test.sh &
Put the sh test.sh task in the background, close xshell, and the corresponding task stops.
Nohup sh test.sh puts the sh test.sh task in the background, shuts off standard input, the terminal can no longer receive any input (standard input), redirects standard output and standard error to the nohup.out file in the current directory, and continues to run even if xshell is closed and exits the current session. Nohup sh test.sh & put the sh test.sh task in the background, but you can still use standard input, the terminal can receive any input, redirect standard output and standard error to the nohup.out file in the current directory, and continue to run even if you close xshell and exit the current session. At this point, I believe you have a deeper understanding of "how to use the nohup command of Linux". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.