Linux shell脚本之判断进程是否在运行

vi proc1.sh
#!/bin/bash

#此脚本期望的参数个数
argno=1

if [ $# -ne $argno ]
then
echo "Usage: 'basename $0' PID-number" >&2
fi

if [ ! -f "/proc/$1" ]
then
echo "Process #$1 is running"
else
echo "No such process running! "
fi

 

./proc1.sh 5728
Process #5728 is running

posted @ 2021-04-13 14:59  zhudaheng123  阅读(2225)  评论(0)    收藏  举报