ps -ef |grep -v 在shell sh 脚本中貌似无效?

 

想经过ps -ef |grep erdp_ |awk '{print $2}' 获取 erdp_ 开头的进程id, 执行在终端环境下执行是ok的,可是在 sh 脚本里面居然多出了 两个java

 

root 11400 4280 0 17:08 pts/5 00:00:00 /bin/bash ./kill.sh erdp_system_appbash

root 11401 11400 0 17:08 pts/5 00:00:00 /bin/bash ./kill.sh erdp_system_appapp

root 11403 11401 0 17:08 pts/5 00:00:00 grep erdp_system_app进程

root 29942 1 3 12:22 pts/0 00:10:10 java -Xms512m -Xmx512m -Dfile.encoding=UTF-8 -DSERVER_PORT=8082 -jar erdp_system_app-2.0.0-SNAPSHOT.war linkServerPId

awk

ps -ef |grep erdp_ |awk '{print $2}' | grep -v 能够过来 第三行, 可是 前面两行是怎么出现的呢?coding

 

 

无论怎么样, 经过下面的命令就行了:file

ps -ef |grep erdp_  |  grep -v | grep -v 文件名 终端

或者: grep

ps -ef |grep erdp_  | grep -vE '(grep|/bin/bash)'脚本

相关文章
相关标签/搜索