hello all,
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 :
Code:
#!/usr/bin/env python
import os
import glob
import commands
import time
location = "/usr/local/testlogs/text/*"
for file in glob.glob(location) :
#print file
st = os.stat(file)
mtime = st.st_mtime
mtime2 = time.gmtime(mtime)
mtime2_hr = time.strftime("%m/%d/&Y %H:%M:%S", mtime2)
print mtime2_hr
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