Batch kill PID process recorded in multiple PID files, and integrate into shell script

Source: Internet
Author: User

1 " *.pid " ` 2  for inch $head _files 3  Do 4     ' {print $} ' | Xargs Kill-95     rm-f $file6 Done

Code as above

Explain:

1. Find all the PID files in the./fmsconf Directory

2. Traverse the found file

3. Start traversing

4. Separate explanations:

1. Cat $file: Print out the contents of file files

2. awk ' {print $} ': Print the first unit character

3. Xargs: Use the previous output as the input for this

4. kill-9: Call Linux bottom, Force kill process

5. deleting files

6. End

Reference Links:

Shell Utility script: bulk copy of files of the same type

"Shell script" line-by-row processing of text files

Linux awk Command

Linux-awk and kill batch kill process

Batch kill PID process recorded in multiple PID files, and integrate into shell script

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.