티스토리 뷰

반응형
#!/bin/sh
#########################################################
# "DaemonManager.sh"
#########################################################
if [ -f ~/.bashrc ]; then
    . ~/.bashrc

PATH=$PATH:$HOME/.local/bin:$HOME/bin
export PATH
export PATH=/usr/local/anaconda3-4.1.0/bin:/usr/local/lib/:$PATH
fi
WORKDIR=~/TEST/BaseUpdateDaemon
DAEMON=daemon.py
LOG=~/TEST/log/daemon.log

function do_start()
{
    cd ${WORKDIR}
    nohup python ${DAEMON} & >> ${LOG}
}

function do_stop()
{
    PID=`ps -ef | grep ${DAEMON} | grep -v grep | awk '{print $2}'`
    if [ "$PID" != "" ]; then
        kill -9 $PID
    fi
}

case "$1" in
    start|stop)
        do_${1}
        ;;

    reload|restart)
        do_stop
        do_start
        ;;
    *)
    echo "Usage: ~/TEST/bin/DaemonManager\.sh {start|stop|restart}"
    exit 1
    ;;
esac
반응형
반응형
최근에 달린 댓글