shell脚本创建多个终端启动多个算法

该.sh脚本用于在Linux环境中实现四个算法程序(contral_cam、wlxd、people_detection_saveImg_jsonk、hook_rush_top_json)的自启动和监控。当任何一个进程终止时,脚本会检测到并重新启动它,确保系统的持续运行。脚本使用了ps命令检查进程状态,并通过gnome-terminal重新启动程序。
摘要由CSDN通过智能技术生成

1、目标

        创建.sh脚本,实现三个算法自启动功能。并实时进行监测进程,当进程断开,则重新自启动算法。

2、实现

#! /bin/bash

export LD_LIBRARY_PATH=/home/mzd/project/ken/vulkan/1.2.162.1/x86_64/lib:./mylib:/home/mzd/project/ken/hikvisionSDK/CH-HCNetSDKV6.1.9.4_build20220413_linux64/lib:/home/mzd/project/ken/json/build/lib:$LD_LIBRARY_PATH
while true
do

    #############################  contral camera  #############################
	{
    monitor1=`ps -ef | grep contral_cam | grep -v grep | wc -l `
    if [ $monitor1 -eq 0 ]
    then
        echo "contral_cam_31_32_ program is not running, restart it"
		gnome-terminal -x bash -c "/home/mzd/project/ken/contral_cam/v4/test.sh;exec bash"
    else
        echo "contral_cam_31_32_ program is running"
    fi
	}&
    sleep 10

    #############################  wlxd  #############################
	{
    monitor2=`ps -ef | grep wlxd | grep -v grep | wc -l `
    if [ $monitor2 -eq 0 ]
    then
        echo "wlxd program is not running, restart it"
        gnome-terminal -x bash -c "/home/mzd/project/ken/wailaxd/v4.1/test.sh;exec bash"
    else
        echo "wlxd program is running"
    fi
	}&
    sleep 7

    #############################  people detection  #############################    
	{
    monitor3=`ps -ef | grep people_detection_saveImg_jsonk | grep -v grep | wc -l `
    if [ $monitor3 -eq 0 ]
	
    then
        echo "people_detection_saveImg_jsonk program is not running, restart it"
        gnome-terminal -x bash -c "/home/mzd/project/ken/fixes_area_peopledetection/v8/test.sh;exec bash"
    else
        echo "people_detection_saveImg_jsonk program is running"
    fi
	}&
    sleep 7
    
    #############################  hook rush top  #############################    
	{
    monitor4=`ps -ef | grep hook_rush_top_json | grep -v grep | wc -l `
    if [ $monitor4 -eq 0 ]
    then
        echo "hook_rush_top_json program is not running, restart it"
		gnome-terminal -x bash -c "/home/mzd/project/ken/hook_rush_top/v5/test.sh;exec bash"
    else
        echo "hook_rush_top_json program is running"
    fi
	}&
    sleep 7
    #############################  protest  #############################    
done



         上述有四个可执行程序contral_cam,wlxd,people_detection_saveImg_jsonk,hook_rush_top_json,实现了依次启动这四个算法,当contral_cam进程断开,则杀死四个进程,并重新依次启动四个算法。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值