首页 > 系统服务 > 详细

Linux 进程守护脚本

时间:2021-02-06 10:44:46      阅读:20      评论:0      收藏:0      [点我收藏+]

一、进程守护脚本:

while true;
do
        server=`ps aux | grep stat-agent-1.0.0-SNAPSHOT.jar | grep -v grep`
        if [ ! "$server" ]; then
           systemctl start statagent.service
        fi
        sleep 20
done

二、开机启动进程守护:

1.创建文件
cd /etc/init.d
vim daemon-stat-agent

 

2.文件内容
#!/bin/sh
#chkconfig: 2345 10 20
#description: daemon-stat-agent

 

cd /usr/local/stathub
nohup ./daemon-stat-agent.sh &

 

3.设置执行权限
chmod +x daemon-stat-agent

 

4.添加开机启动任务
chkconfig --add daemon-stat-agent

 

5.查看开机启动任务
chkconfig --list

 

Linux 进程守护脚本

原文:https://www.cnblogs.com/s0611163/p/14380786.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!