想要让python程序在后台执行(默认python文件名为xxx): nohup python xxx.py & 此时文件输出被追加到nohup.out文件中。如果已经存在nohup.out文件,则建议先将其备份删掉,再执行命令。
想要清空nohup.out文件 cat /dev/null > nohup.out 或者 cp /dev/null nohup.out
想要复制一份nohup.out文件 cp nohup.out nohup_bak.out
想要查看此时的进程状态: ps -ef|grep python 返回的就是进程状态,第二个id就是进程ID,后面显示运行时间
想要强制关闭某个进程: kill -9 pid
想要查看nohup.out文件的内容:
head -n 100 nohup.out <查看前100行内容>
tail -n 100 nohup.out <查看后100行内容>
cat nohup.out|grep “关键字” <过滤关键字所在的行>
想要监控程序输出: tail -f nohup.out
ubuntu + nohup
最新推荐文章于 2024-04-09 12:25:29 发布