1. 程式人生 > >linux判斷程序是否啟動

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