惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

罗磊的独立博客
Cisco Talos Blog
Cisco Talos Blog
C
Check Point Blog
博客园_首页
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Martin Fowler
Martin Fowler
Recorded Future
Recorded Future
S
Security @ Cisco Blogs
L
LINUX DO - 最新话题
博客园 - 司徒正美
P
Privacy International News Feed
G
Google Developers Blog
I
Intezer
Hacker News - Newest:
Hacker News - Newest: "LLM"
博客园 - 聂微东
The GitHub Blog
The GitHub Blog
C
Cybersecurity and Infrastructure Security Agency CISA
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Scott Helme
Scott Helme
K
Kaspersky official blog
I
InfoQ
Y
Y Combinator Blog
T
The Blog of Author Tim Ferriss
Webroot Blog
Webroot Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
大猫的无限游戏
大猫的无限游戏
D
Docker
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
W
WeLiveSecurity
Microsoft Azure Blog
Microsoft Azure Blog
Spread Privacy
Spread Privacy
量子位
H
Hacker News: Front Page
Simon Willison's Weblog
Simon Willison's Weblog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
SecWiki News
SecWiki News
S
Security Affairs
Latest news
Latest news
人人都是产品经理
人人都是产品经理
C
CERT Recently Published Vulnerability Notes
S
Security Archives - TechRepublic
V
Visual Studio Blog
T
Troy Hunt's Blog
S
Secure Thoughts
F
Fortinet All Blogs
V
V2EX
The Register - Security
The Register - Security
J
Java Code Geeks
MongoDB | Blog
MongoDB | Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO

博客园 - 陈达辉

win10安装redis 基于SpringBoot的在线教育系统【源码开源】【建议收藏】 - 陈达辉 eduYouke在线教育点播系统 解决ThinkPHP6 控制器不存在:app\controller\Index - 陈达辉 - 博客园 ubuntu下安装YApi 低版本idea中SpringBoot项目启动失败,提示找不到 javax/servlet/ServletContext类 nginx -s reload 与 service nginx restart 的区别 安装pip install pymysql碰到的问题,升级pip报错:Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-vZoYWX/pip/ Git冲突:commit your changes or stash them before you can merge. 解决办法 安装node、vue相关问题 初学JAVA-10-java代码的组织结构 IntelliJ IDEA 2020.2 破解版(附永久破解激活方法)Java开发者必备的神器 laravel观察者模式使用及注意事项 本地连接虚拟机redis,解决redis connection refused: connect问题 linux如何删除php7 使用vscode开发php nginx: [emerg] open() "/etc/nginx/fastcgi.conf" failed ubuntu php7.2安装php-redis扩展 Ubuntu16.04安装Redis
python 服务器后台运行
陈达辉 · 2021-09-15 · via 博客园 - 陈达辉

基本用法:
进入要运行的py文件目录前

nohup python -u test.py > test.log 2>&1 & //打印日志
nohup xxxx >/dev/null 2>&1 & //不打印日志

含义解释:
nohup 不挂起的意思

python test.py python运行test.py文件

-u 代表程序不启用缓存,也就是把输出直接放到log中,没这个参数的话,log文件的生成会有延迟

test.log 将输出日志保存到这个log中

2>1 2与>结合代表错误重定向,而1则代表错误重定向到一个文件1,而不代表标准输出;
2>&1 换成2>&1,&与1结合就代表标准输出了,就变成错误重定向到标准输出.

& 最后一个& ,代表该命令在后台执行

/dev/null :Linux下有一个特殊的文件/dev/null,它就像一个无底洞,所有重定向到它的信息都会消失得无影无踪。这一点非常有用,当我们不需要回显程序的所有信息时,就可以将输出重定向到/dev/null。

回到shell之后不能直接关闭自己的终端,必须输入exit来退出SSH才能保证该脚本会一直在后台运行

[1] 2880

代表进程2880中运行。

查看nohub命令下运行的所有后台进程:
jobs
查看后台运行的所有进程:
ps -aux

查看后台运行的所有python 进程:
ps aux |grep python
或者

ps -ef | grep python

*删除进程
kill -9 [进程id]