linux命令后台执行python脚本

nohup python xxx.py > nohup.log 2>&1 &

程序将于后台运行。

nohup /opt/work/web/xenwebsite/xenwebsite-env/bin/python2.7 > nohup.log 2>&1 runserver.py &

nohup : 后台运行
/opt/work/web/xenwebsite/xenwebsite-env/bin/python2.7 : python环境
> nohup.log 2>&1 : 错误日志写入 nohup.log
runserver.py & : 运行runserver.py 文件

运行成功他会返回进程id  可以根据进程id关掉这个文件
ps -ef | grep 进程id : 查找这个进程
kill -9 进程id : 杀掉这个进程

 

posted @ 2020-12-29 17:43  你的小可爱吖  阅读(1542)  评论(0编辑  收藏  举报