A shell script that automatically restarts after the monitoring process hangs on Linux

Source: Internet
Author: User

This article describes the shell script, through a while-do loop, with Ps-ef|grep check whether the loader process is running, if not run, then start to ensure that the crash hangs the process, and automatically restart in a timely manner.

The script reads as follows:

Note:
1, PS | grep must add a path to a process, or grep will have an unknown error,
2, you must remove the grep command itself from the result with-V, otherwise the result is not empty.

If you start this shell and discover that the process already exists, it means that the process is started in another way instead of the shell, and it continues to alert you to the process.
Workaround:
Just start the service with this shell , or kill it once you discover that the service started in another way, which is the sentence in the above script:
Kill-9 $pidof $PWD/loader


A shell script that automatically restarts after the monitoring process hangs on Linux

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.