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

时间:2021-04-14 11:51:22   收藏:0   阅读:0

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

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!