判断进程是否存在

#!/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