I am trying to make a cron job to delete the contents of a directory [basically log files] in a linux environment.The contents created before 2 days should get deleted by this job.Here is what i have written :
Two small things....firstly "ctime" is not the "create" time but the "change" time - probably best to read the man page to make sure you understand the difference between mtime and ctime. Secondly you will probably need to escape or quote the wildcard, eg:
I am using this script to delete the files created 5 days ago in /home/directory/ location.
But somehow its not working.Can you please let me know the error in this.
find /home/directory/ -type f -mtime +5 -exec rm {} \;