Linux 检查应用不在现就重启

简介: Linux 检查应用不在现就重启

每5分钟检查一次,如果不在线就重启

#!/bin/bash
count=`ps axu | grep kafka_2.11-1.0.0|grep -v grep|wc -l`
echo "process count => "$count
if [ "$count" != 0 ];then
        echo "kafka is running "
else
        echo "kafka not running"
        #启动 kafka
        echo "开始启动 zookeeper...."
        sh /home/sol/kafka_2.11-1.0.0/bin/zookeeper-server-start.sh -daemon /home/sol/kafka_2.11-1.0.0/config/zookeeper.properties
        sleep 10; 
        echo "开始启动 kafka...."
        sh /home/sol/kafka_2.11-1.0.0/bin/kafka-server-start.sh -daemon /home/sol/kafka_2.11-1.0.0/config/server.properties
        echo "kafka 启动成功"
fi
#crontab -e
#*/5 * * * * /home/sol/startkafka.sh > /tmp/startkafka.log 2>&1 
#startkafka.sh 不能放在 kafka_2.11-1.0.0 里面,否则 grep kafka_2.11-1.0.0 的count 会有数量
#grep kafka_2.11-1.0.0 最好不要写 grep kafka ,防止 count 有值

 

 

 

红字 kafka 可以换成 tomcat 等其它应用

目录
相关文章
|
3天前
|
存储 监控 固态存储
|
21天前
|
Linux
linux关机重启
linux关机重启 登录注销 shutdown -h now 立刻关机 shutdown -h 1 一分钟后重启 shutdown -r now 重启计算机 halt 关机 reboot 重启计算机 sync 内存数据同步到磁盘
|
22天前
|
Linux
linux关机重启
linux关机重启 登录注销 shutdown -h now 立刻关机 shutdown -h 1 一分钟后重启 shutdown -r now 重启计算机 halt 关机 reboot 重启计算机 sync 内存数据同步到磁盘
|
14天前
|
网络协议 安全 Linux
阿里云国际上如何检查 Linux 上正在使用哪些端口
阿里云国际上如何检查 Linux 上正在使用哪些端口
|
23天前
|
Linux
linux关机重启
linux关机重启 登录注销 shutdown -h now 立刻关机 shutdown -h 1 一分钟后重启 shutdown -r now 重启计算机 halt 关机 reboot 重启计算机 sync 内存数据同步到磁盘
|
25天前
|
Linux
linux关机重启
linux关机重启 登录注销 shutdown -h now 立刻关机 shutdown -h 1 一分钟后重启 shutdown -r now 重启计算机 halt 关机 reboot 重启计算机 sync 内存数据同步到磁盘
|
19天前
|
Linux
linux关机重启
linux关机重启 登录注销 shutdown -h now 立刻关机 shutdown -h 1 一分钟后重启 shutdown -r now 重启计算机 halt 关机 reboot 重启计算机 sync 内存数据同步到磁盘 linux关机重启 登录注销 shutdown -h now 立刻关机 shutdown -h 1 一分钟后重启 shutdown -r now 重启计算机 halt 关机 reboot 重启计算机 sync 内存数据同步到磁盘
|
20天前
|
Linux
linux关机重启
linux关机重启 登录注销 shutdown -h now 立刻关机 shutdown -h 1 一分钟后重启 shutdown -r now 重启计算机 halt 关机 reboot 重启计算机 sync 内存数据同步到磁盘
|
26天前
|
Linux
linux关机重启
linux关机重启 登录注销 shutdown -h now 立刻关机 shutdown -h 1 一分钟后重启 shutdown -r now 重启计算机 halt 关机 reboot 重启计算机 sync 内存数据同步到磁盘
|
18天前
|
Linux
linux关机重启
linux关机重启 登录注销 shutdown -h now 立刻关机 shutdown -h 1 一分钟后重启 shutdown -r now 重启计算机 halt 关机 reboot 重启计算机 sync 内存数据同步到磁盘 linux关机重启 登录注销