linux判断进程是否启动

判断进程是否存在


#!/bin/bash

PIDS=`ps -ef|grep 'cardservice'|grep -v grep|awk '{print $2}'`

if [ "$PIDS" != "" ]; then
        echo "process is runing! PID=$PIDS"
else
        echo "process is notrunning PID=$PIDSI"
fi

for 循环


#!/bin/bash

PIDS=`ps -ef|grep 'java'|grep -v grep|awk '{print $2}'`


for pid in $PIDS;
do
        echo "pid=$pid";
done


猜你喜欢

转载自blog.csdn.net/kq1983/article/details/83474084
今日推荐