Skip to content

Commit

Permalink
Included S3 folder deletion if time stamp is older than specified age
Browse files Browse the repository at this point in the history
  • Loading branch information
mcianfrocco committed Apr 9, 2017
1 parent 641655a commit 3c04981
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions aws/delete_temp_s3_ebs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python
import time
import sys
import os
import subprocess
Expand Down Expand Up @@ -58,13 +59,14 @@ for line in open('s3.log','r'):
cmd='aws s3 ls rln-aws-tmp-%s/%s > s3b.log' %(teamname,line.split()[-1].strip())
subprocess.Popen(cmd,shell=True).wait()
for t in open('s3b.log','r'):
query=float(t.split()[-1][:-1])
currtime=time.time()
if '-mic' in t:
t=t[:-5]
query=float(t.split()[-1][:-1])
currtime=time.time()
diff=currtime-query
if diff > s3timelim:
cmd='aws s3 rm s3://rln-aws-tmp-%s/%s/%s/ --recursive > s3tmpout.txt' %(teamname,line.split()[-1].strip(),query)
print cmd
#subprocess.Popen(cmd,shell=True).wait()
cmd='aws s3 rm s3://rln-aws-tmp-%s/%s%.0f/ --recursive > s3tmpout.txt' %(teamname,line.split()[-1].strip(),query)
subprocess.Popen(cmd,shell=True).wait()
os.remove('s3.log')
os.remove('s3b.log')

0 comments on commit 3c04981

Please sign in to comment.