In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the relevant knowledge of "how to use the Linux nohub command". The editor shows you the operation process through the actual case. The operation method is simple, fast and practical. I hope this article "how to use the Linux nohub command" can help you solve the problem.
Basic syntax of nohup command
The basic syntax of the nohup command is as follows:
$nohup command arguments or $nohup options
If you want more information about the use of nohup, check out its help page:
$nohup-- help uses the nohup command to start a program
If you need to run a program that keeps running even after the corresponding Shell is exited, you can run the program using nohup:
$nohup command
When the program starts, the corresponding log output of the program and its error log will be recorded in the nohup.out file, which is usually located in the home directory or the current directory.
The output of the redirector program
If I do not want to save the output of the program in the home directory or the current directory, I want to save it in the path I specified and customize the file name, what should I do? At this point, we can use the redirect operation.
For example, I now have a script myScript.sh that I want to save its output to the output directory in my home directory, with the file name myOutput.txt, which can be run like this:
$nohup. / myScript.sh > ~ / output/myOutput.txt uses the nohup command to start a program in the background
If you want the program to run in the background, you can add the & symbol. But after running in this way, the program disappeared without a trace. To get the program back to the terminal, use the fg command.
The output log of this command will be saved in the nohup.out file, which you can view using cat or other commands. The number 8699 in the second line represents the process number corresponding to the command, that is, pid. We can use the ps command to find this process.
Running multiple programs at the same time using nohup
If you need to run multiple programs at the same time, you don't have to run them one by one, just use the & & symbol. For example, if you want to run mkdir and ping,ls commands at the same time, you can run them like this:
$nohup bash-c 'mkdir files & & ping-c 1 baidu.com & & ls' > output.txt
Stop the process running in the background
As mentioned above, the nohup command combined with the & symbol allows the process to run in the background, even if the terminal is closed. At this point, what do you do if you want to terminate the process?
The simplest is the kill command, which I believe you have used many times.
$kill-9 PID
So how do you find the corresponding pid for the process? We can use the ps command.
$ps aux | grep myScript.sh
Or you can use the pgrep command.
Next, use the kill command to terminate the process.
This is the end of $kill-9 14942 on "how to use Linux nohub commands". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
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.