-1

I am running some tasks that might take 3-4months to complete (datasets transfer) on remote server via ssh, so I used screen to run a python scripts doing the job.

Unfortunately, connection breaks after running for like 6-8 days (this happen twice), despite that I correctly detached all screen sessions (Ctrl+a d)so I have to start all over again (to avoid duplicate in datasets transferred).

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

You can see the connection already closed message above, the script stops after the 596000it iteration (no longer running again)

May I know how to achieve one of the options below to avoid this frustration:

  1. Avoid this connection already closed problem so the python script run until all datasets are completely transferred, OR
  2. Have some way to continue fetching dataset from source database from where the script broke last.
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
arilwan
  • 3,374
  • 5
  • 26
  • 62
  • option 2 looks more realistic. you have the cards in hand. Create a file storing current achieved progress, and implement an option to read back this file to resume computation where it left off – Jean-François Fabre May 14 '19 at 10:50
  • @Jean-FrançoisFabre thank you, I'm not sure how that could be done in python. – arilwan May 14 '19 at 10:55

1 Answers1

1

Maintain a running location of where your script left off and, if you lose connection, where to begin again.

Assuming of course that the data did not change between sessions.

DougM
  • 920
  • 1
  • 9
  • 21