Skip to content

Instantly share code, notes, and snippets.

@andre-brongniart
Created October 26, 2016 07:32
Show Gist options
  • Save andre-brongniart/1a6320a92ec078a720d320fa048bc050 to your computer and use it in GitHub Desktop.
Save andre-brongniart/1a6320a92ec078a720d320fa048bc050 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import os, sys
from os import path
from datetime import datetime, timedelta
def files(path):
for file in os.listdir(path):
if os.path.isfile(os.path.join(path, file)):
yield file
serverpath = "./testing_scripts/"
docs = files(serverpath)
_30_mins_ago = datetime.now() - timedelta(minutes=1)
try:
for doc in docs:
doctime = datetime.fromtimestamp(path.getctime(serverpath + doc))
if doctime < _30_mins_ago:
print doc + " more than 30 minutes old"
else:
print "All document root files checked for sftp user are less than 30 minutes old."
sys.exit(0)
except:
sys.exit(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment