我正在通过ssh在远程服务器上运行一些可能需要3-4个月才能完成(数据集传输)的任务,因此我使用screen
运行python脚本来完成这项工作。
不幸的是,尽管我正确分离了所有screen
个会话(Ctrl+a d
),但连接运行了6-8天(两次)后断开,所以我必须重新开始(以避免在传输的数据集中重复。
root$screen -r
There are several suitable screens on:
7567.noiselevel_script (Detached)
6046.airquality_script (Detached)
1448.weather_script (Detached)
Type "screen [-d] -r [pid.]tty.host" to resume one of them.
root$screen -r 6046.airquality_script
595997it [167:43:10, 1.01s/it]
{"particles": null, "O3": 1.4509, "dateObserved": "2015-06-16T21:54:54+01:00", "name": "FEUP I-181 Calibration", "location": {"coordinates": [-8.594866, 41.178031]}}
595998it [167:43:11, 1.01s/it]
{"particles": null, "O3": 1.50961, "dateObserved": "2015-06-16T21:54:55+01:00", "name": "FEUP I-181 Calibration", "location": {"coordinates": [-8.594866, 41.178031]}}
595999it [167:43:12, 1.01s/it]
{"particles": null, "O3": 1.47883, "dateObserved": "2015-06-16T21:54:58+01:00", "name": "FEUP I-181 Calibration", "location": {"coordinates": [-8.594866, 41.178031]}}
596000it [167:43:13, 1.01s/it]connection already closed
您可以在上方看到连接已关闭消息,脚本在596000it
迭代之后停止运行(不再运行)
我可以知道如何实现以下一种选择来避免这种挫败感:
connection already closed
问题,以便python脚本运行直到所有数据集都被完全传输为止,或者答案 0 :(得分:1)
保持脚本停止运行的位置,如果失去连接,则重新开始。
当然,假设会话之间的数据没有变化。