#!/bin/bash # 使用更精确的方式检查进程 check_process() { ps aux | grep "dotnet.*MicroService_Face_3_0.dll" | grep -v grep > /dev/null return $? } # 检查程序是否运行 if check_process then echo "程序已经在运行中..." # 显示当前运行的进程信息 echo "当前运行的进程信息:" ps aux | grep "dotnet.*MicroService_Face_3_0.dll" | grep -v grep else echo "程序未运行,正在启动..." export LD_LIBRARY_PATH=/mnt/faceserver:$LD_LIBRARY_PATH cd /mnt/faceserver dotnet MicroService_Face_3_0.dll # 等待几秒检查是否成功启动 sleep 3 if check_process then echo "程序启动成功!" ps aux | grep "dotnet.*MicroService_Face_3_0.dll" | grep -v grep else echo "程序启动失败,请检查日志文件" fi fi
标签:Face,grep,echo,任务,ubuntu,dotnet,MicroService,定时,dll From: https://www.cnblogs.com/xiaosongboke/p/18563119