用于定时启动脚本,如果已经启动,y已及检查脚本是否已启动,如果启动就跳过

ubuntu 16.04 

consumer.sh

#!/bin/bash
COUNT=`ps -ef | grep $1 | grep -v grep | wc -l `
echo $COUNT
if [ $COUNT -eq 2 ];
    then
    echo "Starting the consumer @@@@@:"$1
    cd /usr/local/airflow/dags/consumer/
    nohup python3 $1 >output 2>&1 &     
    echo "Started the consumer !"
else
    echo " the consumer has started!"
fi

 

eg:  consumer.sh  hello.py

说明:

COUNT=`ps -ef | grep $1 | grep -v grep | wc -l `    #当前进程数量
echo $COUNT
if [ $COUNT -eq 2 ];
    then
    echo "Starting the consumer @@@@@:"$1
    cd /usr/local/airflow/dags/consumer/    //进入脚本路径
    nohup python3 $1 >output 2>&1 &       //执行脚本 此处 python3  xxx.py  
    echo "Started the consumer !"
else
    echo " the consumer has started!"
fi
posted on 2020-05-28 18:08  lshan  阅读(263)  评论(0编辑  收藏  举报