In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the knowledge of "how to write a Shell script to restart the Centos system in a gentle way". Many people will encounter this dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
The main purpose is to restart important processes in the background. If you use killall-9 to force kill to drop, it may cause problems. Such as database processes. The code is as follows:
The code is as follows:
#! / bin/sh
If [- z "$1"]; then
/ bin/echo "$0"
Exit 1
Fi
Param=''
List='2 3 4 5 6 7 8 9'
For i in $list; do
Eval packs are not available.
If [- z $p]; then
Break
Fi
Param= "$param $p"
Done
If [- f / bin/awk]; then
AWK=/bin/awk
Else
AWK=/usr/bin/awk
Fi
If [- f / bin/grep]; then
GREP=/bin/grep
Else
GREP=/usr/bin/grep
Fi
Program= `/ bin/echo $1 | $AWK-F'/'{print $NF;}'`
Count= `/ bin/ps auxww | $GREP-w $program | $GREP-v grep | / usr/bin/wc-l`
If [$count-gt 0]; then
ITunes 0
/ bin/echo "stopping $program..."
While [1-eq 1]; do
If [$I-eq 0]; then
/ usr/bin/killall $program
Else
/ usr/bin/killall $program > / dev/null 2 > & 1
Fi
If [$?-ne 0]; then
Break
Fi
/ usr/bin/printf.
/ bin/sleep 1
Let i=$i+1
Done
Fi
/ bin/echo ""
Count= `/ bin/ps auxww | $GREP-w $program | $GREP-v grep | $GREP-v $0 | / usr/bin/wc-l`
If [$count-eq 0]; then
/ bin/echo "starting $program..."
Exec $1$ param
Else
/ bin/ps auxww | $GREP-w $program | $GREP-v grep | $GREP-v $0
/ bin/echo "already running $program count: $count, restart aborted!"
Fi
This is the end of "how to write a Shell script to gently restart the Centos system". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.