我是bash脚本的新手,并且发现了一个来自stackoverflow的代码。我将它与我的脚本合并,它不会运行python。当我试图回应时,它总是会“很好”。当我试图运行ps -ef | grep runserver*
时,它总是出现并导致python脚本无法运行。运行python脚本的Bash脚本
root 1133 0.0 0.4 11988 2112 pts/0 S+ 02:58 0:00 grep --color=auto runserver.py
这里是我的代码: -
#!/bin/sh
SERVICE='runserver*'
if ps ax | grep -v grep | grep $SERVICE > /dev/null
then
python /var/www/html/rest/runserver.py
python /var/www/html/rest2/runserver.py
else
echo "Good"
fi
的答案在这里http://stackoverflow.com/questions/2903354/bash-script-to-check-running-process – haifzhan
这篇帮助? https://stackoverflow.com/questions/4377109/shell-script-execute-a-python-program-from-within-a-shell-script – Windsooon
@HaifengZhang我用过那个例子,它没有工作......这就是为什么我要求另一个解决方案 – NickyMan