shell脚本:可以查询指定进程的状态

昨晚上临下班的时候项目经理说在主机上查询进程一个个找起来太繁琐了,让我去写一个shell脚本,可以固定查询几个主机进程。

我是研发部的实习生,我从来没接触过shell,只是简单的使用linux命令。

然后我就去看了下shell文档,我发现shell是真的很简单,逻辑思维和c基本一致。

下面源码奉上

 

 

#! /bin/bash
a="GNERR_A" 
b="NG_IGNS"
c="TIMER_C"
d="NG_IBSB" 
e="NG_CLPAT" 
f="NG_DSMPA"
ps aux|grep -q "^$a"
case $? in
    0)
        echo " $a is  running"
        ;;
    *)
        echo "$a is not running"
esac
ps aux|grep -q "^$b"
case $? in
    0)
        echo " $b is  running"
        ;;
    *)
        echo "$b is not running"
esac
ps aux|grep -q "^$c"
case $? in
    0)
        echo " $c is  running"
        ;;
    *)
        echo "$c is not running"

esac
ps aux|grep -q "^$d"
case $? in
    0)
        echo " $d is  running"
        ;;
    *)
        echo "$d is not running"
     
esac
ps aux|grep -q "^$e"
case $? in
    0)
        echo " $e is  running"
        ;;
    *)
        echo "$e is not running"
      
esac
ps aux|grep -q "^$f"
case $? in
    0)
        echo " $f is  running"
        ;;
    *)
        echo "$f is not running"
       
esac

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Ave_lmy

你的鼓励是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值