I have a cron job that deletes files based on their age using the command:
find /path/to/file/ -type f -mmin +120|xargs -I file rm 'file'
However I’d like to integrate the command into a python script which involves the task as well as other things that also run on cron.
I understand I could just plonk the command as it is into the Python script and it would probably run find, however I’m interested to know there a more Python-centric way to accomplish this and what other benefits might that bring?
My method would be:
Edit: I tested it, it didn’t work, so i fixed the code and i can confirm it works.