我正在尝试获取作为子进程运行的Airflow Scheduler的状态。它在父进程中运行16次。
1000 10001 56898 51 13:07 pts/9 00:00:00 /usr/bin/python2.7 /usr/local/bin/airflow scheduler
1000 10002 56898 43 13:07 pts/9 00:00:00 /usr/bin/python2.7 /usr/local/bin/airflow scheduler
1000 10003 56898 43 13:07 pts/9 00:00:00 /usr/bin/python2.7 /usr/local/bin/airflow scheduler
1000 10004 56898 42 13:07 pts/9 00:00:00 /usr/bin/python2.7 /usr/local/bin/airflow scheduler
etc..... running 16 times .
如果服务停止,它应该每30分钟发送一次电子邮件。如果进程正在运行,则不应该。
只是思考是可能的。如果有人通过回复电子邮件确认应停止电子邮件警报。
PPID=$(ps -ef | grep -i 'airflow scheduler' | grep -v grep | awk '{print $2}')
if [[ -z ${PPID} ]]; then
echo " Airflow is not running >>pp.txt
mail -s "Airflow process ALERT" abc@xyz.com <pp.txt