#!/bin/bash
var=$(ps -ef | grep process_name | grep -v grep | wc -l)
if [ $? = 0 ] ;
then
echo " this program is not exist!"
else
echo " this program is exist!"
var=$(ps -ef | grep process_name | grep -v grep | wc -l)
if [ $? = 0 ] ;
then
echo " this program is not exist!"
else
echo " this program is exist!"
fi
(process_name为进程名字)把以上存为一个.sh后缀的文件,执行方法: ./test.sh