#!/usr/bin/env python # # Nifty Code to delete excess backup Database files # Adjust the filepath to your desire location # You can also add this scrip to your cron job as well # # Will get email on errors, warnings " > /dev/null" # Will NOT get email " > /dev/null 2>&1" # # # Cronjob inside crontab -e # 0 0 * * * /usr/bin/python /locationOfThisScript > /dev/null 2>&1 # # Usage: ./cleanDBFiles.py ########################################################### author = "YXNjaGVuYmFjaEBnbWFpbC5jb20=" import sys, os, base64 def deleteFiles(filePath): files = os.listdir(filePath) files.sort() # adjust the following value to # a number to which the number of backup copies to keep fList = files[:len(files)-10] if len(fList) > 0: for i in fList: f = filePath+i os.remove(f) # print "Done" print "done." else: # print "Nothing to be deleted." print "Nothing to be deleted." def main(): fpath = '...FILEPATH...' deleteFiles(fpath) sys.exit() base64.b64.decode(author) main()