19,613
社区成员
发帖
与我相关
我的任务
分享
processExist="`ps aux|grep queue_mail_aaa|grep -v grep`" #查找有没有这个脚本的进程,排除掉grep那条
serviced="nohup /usr/bin/python /home/myservice/queue_mail_aaa.py &" #没有启动时执行的命令
if [ -z $processExist ];then #-z表示是否不存在
#执行这个命令
echo "process is starting...."
$serviced
else
echo "process is running"
fi
processExist="`ps aux|grep queue_mail_bbb|grep -v grep`" #查找有没有这个脚本的进程,排除掉grep那条
serviced="nohup /usr/bin/python /home/myservice/queue_mail_bbb.py &" #没有启动时执行的命令
if [ -z $processExist ];then #-z表示是否不存在
#执行这个命令
echo "process is starting...."
$serviced
else
echo "process is running"
[Unit]
Description=Mems API Service
After=network.target
[Service]
Type=simple
User=mems
WorkingDirectory=/home/mems/api
ExecStart=/opt/pgsql/jdk1.8.0_65/bin/java -jar mems-apigateway-1.0-SNAPSHOT.jar
Restart=on-failure
RestartSec=1
SuccessExitStatus=143
[Install]
WantedBy=multi-user.target
进程飞了会自动重启服务,开机也会自启。还自带命令看服务状态。