Linux process multi-process number real-time monitoring

Source: Internet
Author: User

First, demand:

A process with a process name that may correspond to multiple process numbers is monitored on Linux, and output to a log file if there are multiple.

The above problem is for a timed program has not run the end, to the next moment the program is running again, to avoid causing repeated calls interface error.

Second, the settlement:

#!/Bin/sh# (Sh pid_monitor.sh)&#被监控的进程放在后台运行 whiletrue #死循环不断监控后台运行的进程do pid_num=' PS-Ef|Grep-V grep|grep root_sub_i2_data|Awk'{print $}'|Wc-l ' #取后台运行程序的进程号数量if [$pid _num-gt 1]; #判断被监控的进程数是否大于1, note the semicolon, the shell and Python are different ThenEcho'to monitor multiple exception processes:' >>Pid_monitor.LogPS-Ef|Grep-V grep|grep root_sub_i2_data|Awk'{print $2,$5}' >>Pid_monitor.Log#打印进程号和启动时间Elseecho ' Date ''only monitor the number of 1 processes, normal ...' >>Pid_monitor.LogSleep -#休息30秒 Fidone

Third, reference

Http://blog.chinaunix.net/uid-30106268-id-5030040.html

Http://www.jb51.net/article/34332.htm

Linux process multi-process number real-time monitoring

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.