美文网首页
Python虚拟环境中后台运行脚本

Python虚拟环境中后台运行脚本

作者: jumo | 来源:发表于2020-03-11 11:33 被阅读0次

    新建“start.sh”脚本文件,拷贝以下内容到文件,注意修改自己的脚本文件名。

    #!/bin/sh

    pid=`ps -ef|grep "python -u 需要启动的脚本文件名.py"| grep -v "grep"|awk '{print $2}'`

    if [ "$pid" != "" ]

    then

            echo "需要启动的脚本文件名.py already run, stop it first"

            kill -9 ${pid}

    fi

    cd /www/wwwroot/python/ # 切换到虚拟环境目录

    source venv/bin/activate

    nohup python -u 需要启动的脚本文件名.py > 需要启动的脚本文件名.out 2>&1 &

    相关文章

      网友评论

          本文标题:Python虚拟环境中后台运行脚本

          本文链接:https://www.haomeiwen.com/subject/msjqjhtx.html