我写了一个下面给出的shell脚本
unicorn_cnt=$(ps -ef | grep -v grep | grep -c unicorn)
if (( $unicorn_cnt == 0 )); then
echo "Unicorn Stopped" | mail -s "Alert - Unicorn" someone@somedomin.com
fi
delayed_job_cnt=$(ps -ef | grep -v grep | grep -c delayed_job)
if (( $delayed_job_cnt == 0 )); then
echo "Delayed Job Stopped" | mail -s "Alert - Unicorn" someone@somedomin.com
fi
rake_cnt=$(ps -ef | grep -v grep | grep -c rake)
if (( $rake_cnt == 0 )); then
echo "Convertion Stopped" | mail -s "Alert - Unicorn" someone@somedomin.com
fi
这是用于检查进程是否正在运行,如果没有发送警报邮件。我对shell脚本不太熟悉。运行时显示以下错误。
process.sh: 3: process.sh: 2: not found
process.sh: 7: process.sh: 0: not found
process.sh: 11: process.sh: 0: not found
从我部分理解的一些研究中,这是因为创建变量时的空间问题。没有把握。我尝试使用一些解决方案,例如sed和read。但它仍然显示错误。谁能帮我。
感谢和问候