Skip to content

@cbare /checkpoint.py
Last active

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
create a new directory and put a checkpoint in it
#!/usr/bin/python
# crontab -e
# */20 * * * * /home/ubuntu/checkpoint.py > /home/ubuntu/checkpoint.log 2>&1
import os
hosts = []
with open('/usr/local/Rmpi/hostfile.plain') as f:
for line in f:
hosts.append(line.split()[0])
os.chdir("/home/ubuntu/large1")
if os.path.exists('checkpoint_counter'):
with open('checkpoint_counter') as f:
i = int(f.read())
else:
i = 1
try:
os.mkdir("checkpoint%d" % i)
os.chdir("checkpoint%d" % i)
for host in hosts:
print('scp -i ~/cbare-sage.pem ubuntu@%s:/home/ubuntu/dose.large.node*.tsv .' % host)
os.system('scp -i ~/cbare-sage.pem ubuntu@%s:/home/ubuntu/dose.large.node*.tsv .' % host)
os.chdir('..')
with open("checkpoint_counter", "w") as f:
f.write("%d\n" % (i+1))
except Exception, e:
print("Error: " + str(e))
finally:
os.chdir("/home/ubuntu/")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.