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 > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article shows you what the Linux background operation commands are, which are concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
Linux background running command cron and crontab at are introduced in the previous two commands which will be described later & using this command will not occupy the terminal and will put the process into the background to run. Still want to talk about Linux background running commands to compare learning, combined with examples more impressive.
&
When running a job in the foreground, the terminal is occupied by the job; when running the job in the background, it does not occupy the terminal. You can use the & command to put the job in the background.
The general form of the command is:
Command &
Be careful when running jobs in the background: commands that require user interaction should not be executed in the background, because your machine will be waiting there.
However, running the job in the background will also output the results to the screen, interfering with your work. If a job running in the background produces a large amount of output, * * use the following method to redirect its output to a file:
Command > out.file 2 > & 1 &
In the above example, 2 > & 1 means that all standard output and error output will be redirected to a file called out.file.
When you successfully submit a process, a process number is displayed that you can use to monitor the process or kill it.
Example 1:
Find the file named "httpd.conf" and redirect all standard output and error output to f i n d. D t in the file:
# find / etc/httpd/-name "httpd.conf"-print > find.dt 2 > & 1 &
[2] 7832
[1] Done find / etc/-name "httpd.conf"-print > find.dt 2 > & 1 &
After successfully submitting the command, the system gives its process number 7832.
# cat find.dt
/ etc/httpd/conf/httpd.conf
[2] + Done find / etc/httpd/-name "httpd.conf"-print > find.dt 2 > & 1 &
Check the find.dt and you can see the execution result
Example 2:
Execute scripts in the background, for example, there is a script called psl
$ps psl &
[7878]
Use the ps command to view the process
Use the process number you get when you submit the command to monitor its operation. List this process with the p / s command and the g r e p command:
# ps-x | grep 7832
7868 pts/0 S 0:00 grep 7832
If the system does not support the ps x command, you can use:
# ps-ef | grep 7832
Root 7866 7790 0 23:40 pts/0 00:00:00 grep 7832
When listing a process with the p / s command, it cannot determine whether the process is running in the foreground or in the background.
Kill the background process
You can use the k i l l command to kill the background process. When a process is run in the background, s h e l l will give you a process number, according to which we can kill the process with the k i l l command. The basic form of the command is:
Kill-signal [process_number]
Don't consider the different signals for the time being.
When killing a process, execute the following command (your process number may be different) and press enter. The system will give the appropriate information to tell the user that the process has been killed.
$kill 7832
If the system doesn't give you any information telling you that the process has been killed, wait a while, maybe the system is killing the process, and if it hasn't responded, execute another k i l l command, this time with a signal option:
$kill-9 7868
If a background process is submitted using the above method, the process will be terminated on exit. The next lecture will also introduce another Linux background running command n o h u p.
What are the above contents of Linux background running commands? have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
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.