为什么单独执行和脚本中的取值不一样?
大家好:
我的系统环境是 Solaris 10,我单独执行这条命令取进程数的值 ps -ef | grep -i nbftclnt | grep -c -v grep 是0,
但放在以下脚本中:
#!/bin/bash
ps_cnt=`ps -ef | grep -i nbftclnt | grep -c -v grep`
echo $ps_cnt
if [ $ps_cnt -lt 1 ];then
/usr/openv/netbackup/bin/nbftclnt
fi
---
echo $ps_cn 输出的值是2,检查是没有nbftclnt进程存在的。
---
请问这是什么原因导致的? 应怎么在脚本中准确取进程数?
谢谢!