title: GNU Screen: connection already closed
body: <p>I am running some tasks that might take 3-4months to complete (datasets transfer) on remote server via ssh, so I used <code>screen</code> to run a python scripts doing the job.</p>
  
  <p>Unfortunately, connection breaks after running for like 6-8 days (this happen twice), despite that I correctly detached all <code>screen</code> sessions (<code>Ctrl+a d</code>)so I have to start all over again (to avoid duplicate in datasets transferred).</p>
  
  <pre><code>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
  </code></pre>
  
  <p>You can see the <strong>connection already closed</strong> message above, the script stops after the <code>596000it</code> iteration (no longer running again)</p>
  
  <p>May I know how to achieve one of the options below to avoid this frustration:</p>
  
  <ol>
  <li>Avoid this <code>connection already closed</code> problem so the python script run until all datasets are completely transferred, OR</li>
  <li>Have some way to continue fetching dataset from source database from where the script broke last.</li>
  </ol>