最近由于工作原因要在/etc/init.d/auditd配置文件中加入以下shell代码
if [ `ps aux|grep breach|wc -l >“2” ` ] ; then
killproc breach >/dev/null
fi
目的是因为在维护模式切换到正常模式时,会开启审计服务,会产生多个breach进程,导致系统启动很慢。所以要在启动服务时查看启动了几个breach进程,如果超过2个就杀死多于2个的。![](http://blog.chinaunix.net/blog/image/editor/pb/18.gif)
![](http://blog.chinaunix.net/blog/image/editor/pb/18.gif)
但是每次系统重启这个服务时会生成一个2的文件,这个让我感觉到很奇怪。经过多次测试,确定是>"2"这块出问题了,因为“>”在shell中代表两个意思,一个是大于号,一个是重定向。所以我把“>”改为
-gt 就好了。![](http://blog.chinaunix.net/blog/image/editor/pb/20.gif)
![](http://blog.chinaunix.net/blog/image/editor/pb/20.gif)