Changed file age to 3 days. Will delete file from archive after it's 30 days old.
This commit is contained in:
8
main.py
8
main.py
@@ -24,9 +24,15 @@ if remoteOn is True:
|
|||||||
for file in os.listdir(local_path):
|
for file in os.listdir(local_path):
|
||||||
t = os.path.getmtime(local_path + file)
|
t = os.path.getmtime(local_path + file)
|
||||||
age = (time.time() - t) / 86400
|
age = (time.time() - t) / 86400
|
||||||
if age >= 7:
|
if age >= 3:
|
||||||
shutil.move(local_path + file, remote_path + file)
|
shutil.move(local_path + file, remote_path + file)
|
||||||
logging.info('-- Moved %s', file)
|
logging.info('-- Moved %s', file)
|
||||||
|
for file in os.listdir(remote_path):
|
||||||
|
t = os.path.getmtime(remote_path + file)
|
||||||
|
age = (time.time() -t) / 86400
|
||||||
|
if age >= 30:
|
||||||
|
os.remove(remote_path + file)
|
||||||
|
logging.info('-- Deleted %s', file)
|
||||||
else:
|
else:
|
||||||
print('Not connected')
|
print('Not connected')
|
||||||
logging.info(' -- Error - Server Not connected')
|
logging.info(' -- Error - Server Not connected')
|
||||||
|
|||||||
Reference in New Issue
Block a user