#!/bin/bash
./MyApp&
# 根据情况调整
sleep 3
result=$(ps -aux | grep MyApp | wc -l)
# 使用$(xxx)得到指令执行的结果,
# 变量定义时等号两边不要有空格
echo $result
# if空格[[空格$result空格-gt空格1]];then
if [[ $result -gt 1 ]];then
echo "app start sucessed"
else
echo "app started error"
echo "start the other app"
fi
shell脚本判断程序是否启动
最新推荐文章于 2025-02-25 13:06:44 发布