In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces the example analysis of nohup and & commands in xshell, which has certain reference value. Interested friends can refer to it. I hope you will gain a lot after reading this article. Let Xiaobian take you to understand it together.
nohup
The nohup command runs the command specified by the Command parameter and any associated Arg parameters, ignoring all SIGHUP signals. Run programs in the background using the nohup command after logging out. To run the nohup command in the background, add an &(symbol for "and") to the end of the command.
Nohup is short for no hang up, meaning not to hang up.
The nohup command: If you are running a process and you think it will not end when you exit your account, use the nohup command. This command allows you to continue running the process after you log out of the account/close the terminal.
By default, all output from this job is redirected to a file named nohup.out.
back to top
case
1. 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 standard error (2) to standard output (&1), which is redirected to myout. file.
2. 0 22 * * * /usr/bin/python /home/pu/download_pdf/download_dfcf_pdf_to_oss.py > /home/pu/download_pdf/download_dfcf_pdf_to_oss.log 2>&1
This is a timed task placed in crontab, afraid of this task at 22 pm, start this python script and write the log in the download_dfcf_pdf_to_oss.log file.
back to top
Difference between nohup and &
&: means running in the background
nohup: run without hanging up, note that there is no background running function, that is, running the command with nohup can make the command execute permanently, and has nothing to do with the user terminal. For example, if we disconnect SSH, it will not affect its operation. Note that nohup does not mean background running;& is background running.
& is meant to run in the background, but when the user pushes (hangs), the command automatically exits
Well, we can cleverly combine them to use, that is,
nohup COMMAND &
This allows commands to be executed permanently in the background.
For example:
1. sh test.sh &
Put the sh test.sh task in the background, even if you close the xshell and exit the current session, it will continue to run, but the standard output and standard error messages will be lost (missing log output)
Put the sh test.sh task in the background, close xshell, and the corresponding task stops.
2. nohup sh test.sh
Put the sh test.sh task in the background, turn off standard input, the terminal can no longer accept any input (standard input), redirect standard output and standard error to the nohup.out file in the current directory, and continue to run even if you close the xshell and exit the current session.
3. nohup sh test.sh &
Put the sh test.sh task in the background, but still use standard input, the terminal can accept 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 the xshell and exit the current session.
Thank you for reading this article carefully. I hope that the article "Example Analysis of Nohup and & Commands in xshell" shared by Xiaobian will be helpful to everyone. At the same time, I hope that everyone will support you a lot and pay attention to the industry information channel. More relevant knowledge is waiting for you 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.