如何编写一个shell脚本查看某个进程是否在运行

我需要做一个shell脚本,运行在Linux上,检查某个进程是否在运行,如果在运行则返回1,不在运行则返回0,在下对shell脚本不是很熟,请大家帮忙解决一下,谢谢啦~~

ps:进程名称不能写死,应该是执行命令是传入的参数

[code="java"]#!/bin/bash
PROC_NAME=$1
ProcNumber=ps -ef |grep $PROC_NAME|grep -v grep|wc -l
if [ $ProcNumber -le 0 ];then
result=0
else
result=1
fi
echo ${result}[/code]

asyty的回答少了匹配整个进程名字的逻辑,grep应该加上 -w选项
#!/bin/bash

PROC_NAME=$1

ProcNumber=ps -ef |grep -w $PROC_NAME|grep -v grep|wc -l

if [ $ProcNumber -le 0 ];then

result=0

else

result=1

fi

echo ${result}