In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how to use the dynamic monitoring command watch in linux. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Watch can help you monitor the results of a command to monitor changes in the results of all commands you want.
1. Repeat a command root@jaking-virtual-machine:~# watch-n 1 cat hello.txtEvery 1. 0s: cat hello.txt jaking-virtual-machine: Tue Mar 19 19:13:33 2019Hello Worldwaters Hello Jakingbones 2. Highlight change content root@jaking-virtual-machine:~# watch-d uptime # to highlight the changes, you can use the-d (difference) parameter. Every 2.0s: uptime jaking-virtual-machine: Tue Mar 1919 up 14 days 01 201919 days, 12:53, 2 users, load average: 0.01,0.01,0.00 (omitted here, the change will be highlighted, very easy to observe) 3. Exit root@jaking-virtual-machine:~# watch-n 1-e cat hello.txt # to run a command when there is an error in execution. When the exit code is not 0, that is, the command ends when something goes wrong. You can use the-e (errexit) parameter. Every 1.0s: cat hello.txt jaking-virtual-machine: Tue Mar 19 19:16:49 2019
Open another terminal, perform the mv operation, and you can see the effect:
Root@jaking-virtual-machine:~# mv hello.txt / tmp# new terminal root@jaking-virtual-machine:~# watch-n 1-e cat hello.txt# old terminal Every 1.0s: cat hello.txt jaking-virtual-machine: Tue Mar 19 19:16:49 2019cat: hello.txt: No such file or directory4. Exit root@jaking-virtual-machine:~# watch-n 1-g'du-b hello.txt' Every 1.0s: du-b hello.txt jaking-virtual-machine: Tue when the execution result changes Mar 19 19:23:41 201927 hello.txt opens another terminal to perform echo operation You can see the effect: root@jaking-virtual-machine:~# echo "watch-n-l-g command" > > hello.txt# new terminal root@jaking-virtual-machine:~# watch-n 1-g'du-b hello.txt' # old terminal Every 1.0s: du-b hello.txt Jaking-virtual-machine: Tue Mar 19 19:21:55 201950 hello.txt# now watch-n 1-g'du-b hello.txt' run ends root@jaking-virtual-machine:~# Thank you for reading! This is the end of the article on "how to use the dynamic monitoring command watch in linux". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
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.