ive been trying to search for an answer but its so hard to find a proper answer, here is my problem. In a linux machine, i want to check for files age and remove them if they are older than 2 hours. but i can get the st_mtime but dont know how to convert that to "how may minutes from now". this is the python script i created so far :
location = "/usr/local/testlogs/text/*"
for file in glob.glob(location) :
st = os.stat(file)
mtime = st.st_mtime
mtime2 = time.gmtime(mtime)
mtime2_hr = time.strftime("%m/%d/&Y %H:%M:%S", mtime2)
the output i get show's when the file was last modified in "%m/%d/&Y %H:%M:%S" format. how to get it to ONLY minutes from now format. please help im new to python