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\'
use os.popen()
os.popen()
>>>os.popen("find /path/to/file/ -type f -mmin +120|xargs -I file rm 'file'")
or you can use the subprocess module:
subprocess
>>> from subprocess import Popen, PIPE >>> stdout= Popen(['ls','-l'], shell=False, stdout=PIPE).communicate() >>> print(stdout)