In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article focuses on "how to set up linux server process monitoring and automatic restart", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to set up linux server process monitoring and automatic restart.
First, we need to add a new task to crontab.
# crontab-e: when you enter the editing state, you actually use vi to edit.
* / 1 * sh / root/monitor.sh
I'm simply setting up to call one shell script monitor.sh per minute. Here can be configured more powerful, you can search for crontab tutorials, there are many such tutorials on the Internet.
It should be noted here that many tutorials use / root/monitor.sh directly when configuring command. When I set it up, I found that this configuration will not execute the shell script, which can be done with sh before.
Then we started writing the shell script monitor.sh.
#! / bin/sh proc_name= "WorldFrame_d"
# process name proc_num ()
# query the number of processes
{
Num= `ps-ef | grep $proc_name | grep-v grep | wc-l`
Return $num} proc_num number=$?
# get the number of processes
If [$number-eq 0]
# if the number of processes is 0then
# restart the server, or expand something else.
Cd / longwen/server/sbin/linux;. / WorldFrame_d-c 1fi
My script simply detects the existence of the process and automatically restarts the server if it does not exist.
It can also be extended here, such as the processing of log files and the recording of restart time, and so on.
It should be noted that when editing sh files in windows, you should pay attention to the format (CR/LR), otherwise it is prone to sh execution errors of BUG.
At this point, I believe you have a deeper understanding of "how to set up linux server process monitoring and automatic restart". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.