登录远程服务器运行的程序,退出服务器仍然运行的方法

一、可以使用nohup:

# nohup 命令 目标对象
nohup python train.py
# 退出xshell,建议不要直接关闭,而是使用下面的命令退出
exit
# 查看后台运行和杀死程序的命令
ps -ef | grep train
kill -9 2215

在这里插入图片描述

二、可能出现的问题:

nohup: ignoring input and appending output to 'nohup.out'

在这里插入图片描述
解决方式:

#1、原因
#是因为使用 nohup 会产生日志文件,默认写入到 nohup.out
#2、解决
#将 nohup 的日志输出到 /dev/null,这个目录会让所有到它这的信息自动消失
nohup python train.py > /dev/null 2> /dev/null &

三、参考文章:

1、https://www.cnblogs.com/yebaofang/p/11953342.html
2、https://blog.csdn.net/qq_41375318/article/details/105917271


版权声明:本文为mdllll原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。