我正在尝试做的是在没有启动的情况下启动一个进程。这是我的尝试
#!/bin/bash
pid=`ps ax | grep app | grep -v grep | wc -l`
if [ $pid = 0 ]
then
/etc/init.d/app start
fi
问题是线路
/etc/init.d/app start
未执行。这里有什么问题? 我知道我可以使用 daemontools,但我喜欢“bash”方法。
最佳答案
看看 ==
运算符。
最好的可能是这样的
pid=`ps ax | grep app | grep -v grep`
test -z "$pid" && /etc/init.d/app start
关于linux - 如果死了就开始进程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9992809/