Linux care process script

Source: Internet
Author: User

Linux care process Script 1. Care Process script. The working principle is to use shell to constantly query the process. If the process does not exist, start the process. If you start with gnome, you need to start the script on the GUI. Start. sh Js Code #! /Bin/bash # program directory path PRO_PATH = "/opt/bin/" # program name PRO_NAME = "Record" # program path, not need configure. PRO_MAIN = $ PRO_PATH $ PRO_NAME # GNOME start program, not need configure. PROGRAM_GNOME = "gnome-terminal-e \" $ PRO_MAIN \ "" # start method GNOME or nohup (eg: GNONE --> STAR_PRO = $ PROGRAM_GNOME; nohup --> STAR_METHOD = $ PRO_MAIN) STAR_METHOD = $ PROGRAM_GNOME while true; do PRO_NOW = 'ps aux | Grep $ PRO_NAME | grep-v grep | wc-l 'if [$ PRO_NOW-lt 1]; then $ STAR_METHOD 2>/dev/null 1> & 2 & date> $ PRO_PATH/tinfo. log echo "------------------ $ PRO_MAIN start --------------------"> $ PRO_PATH/tinfo. log fi sleep 10 done exit 0 2. start the process script. If start. sh is directly started on the client, the program started on the client will die. After the process is started, the client is turned off and the process still exists. Bhstart. shJs Code #! /Bin/bash./start. sh & 3. Close the startup process script. Bhstop. shJava Code #! /Bin/bash # progress name PRO_NAME = "Record" ps-ef | grep $ PRO_NAME | grep-v grep | awk '{print $3}' | xargs kill echo "kill start. sh done! "Ps-ef | grep $ PRO_NAME | grep-v grep | awk '{print $2}' | xargs kill echo" kill $ PRO_NAME done"

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.