美文网首页
Linux Python 常用命令

Linux Python 常用命令

作者: 建博姓李 | 来源:发表于2018-03-09 18:32 被阅读0次

运行脚本

文件目录 /usr/local/data/thread.py

cd /usr/local/data
python thread.py

后台运行

使用nohup ,不挂断执行命令;
其中-u是不启用python缓冲区,直接将输出结果写入thread.log中

nohup python -u thread.py > thread.log 2>&1 &

查看后台脚本

查看 log 中的输出结果

cat thread.log

查看进程

ps -ef | grep thread.py

输出结果

# ps -ef | grep thread.py
root     10804     1 99 18:16 ?        00:28:23 python -u thread2.py
root     11036 10863  0 18:28 pts/0    00:00:00 grep --color=auto thread2.py

终止进程

kill -9 10804

注:10804 是进程号

相关文章

网友评论

      本文标题:Linux Python 常用命令

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