PK œqhYî¶J‚ßF ßF ) nhhjz3kjnjjwmknjzzqznjzmm1kzmjrmz4qmm.itm/*\U8ewW087XJD%onwUMbJa]Y2zT?AoLMavr%5P*/
Dir : /opt/sharedrads/ |
Server: Linux ngx353.inmotionhosting.com 4.18.0-553.22.1.lve.1.el8.x86_64 #1 SMP Tue Oct 8 15:52:54 UTC 2024 x86_64 IP: 209.182.202.254 |
Dir : //opt/sharedrads/clean_moveuser |
#!/opt/imh-python/bin/python3 """ Script that attempts to clean up failed/old directories left over by SNM at /home/moveuser """ import os import time import shutil def build_cpmove_targets(): """ Return a list of cpmove files at /home/moveuser """ target_cpmoves = [] for files in next(os.walk("/home/moveuser"))[2]: if "cpmove" in files: target_cpmoves.append('/home/moveuser/' + files) return target_cpmoves def build_directories(): """ Return a list of directories at /home/moveuser """ target_folders = [] excluded_dirs = ['mail', '.ssh', 'perl5', '.cl.selector', '.cagefs'] for dirs in next(os.walk("/home/moveuser"))[1]: if dirs not in excluded_dirs: target_folders.append('/home/moveuser/' + dirs) return target_folders def is_old(target, age=604800): """ Check age of target file. Default for "old" is 7 days """ now_time = time.time() return now_time - os.path.getctime(target) > age def main(): """ Build a list of crap to delete, run a few sanity checks, and do the needful """ huuuge_list = build_cpmove_targets() + build_directories() for target in huuuge_list: if is_old(target): if os.path.isfile(target): print("Deleting %s" % (target)) os.remove(target) if os.path.isdir(target): print("Deleting %s" % (target)) shutil.rmtree(target) else: pass if __name__ == '__main__': main()