vscode ssh中让程序在服务器后台运行并将结果保存到log中

参考:https://cloud.videojj.com/help/docs/faq.html#id10

假设这里要训练的目标文件是gcn_res_cs.py

1、将程序放到后台运行,将标准输出和错误输出写入到 .log 文件中

nohup python gcn_res_cs.py > ./gcn_res_cs.log 2>&1 &

2、查看实时日志中的输出结果。

注意,在 Python 3 中需要使用 print("", flush=True) 让日志实时的写到文件中。

tail -f ./gcn_res_cs.log

3、查看是进程PID以及是否正在运行

ps aux | grep gcn_res_cs.py

4、终止后台正在运行的进程,PID替换为实际进程号,如果无法终止,使用 kill -9

kill -15 PID

猜你喜欢

转载自blog.csdn.net/weixin_41650348/article/details/115353219