My application creates directories when user performs certain action. These directories are stored on my machine for exactly one hour and than are deleted.
Now I would like to move the 'deleting logic' part of application into a cron job that will run every minute.
Let's say that directories for deletion are located in /tmp/files/
. The script should check all directories in this path and delete all that was created one hour ago.
Any help would be appreciated.
Thanks in advance!
** SOLVED **
This will do the trick:
find ./* -mmin +60 -type d -exec rm -rdf {} \;
Best Answer
You shouldn't use
find ./*
because this causes the shell to expand the wildcard before invokingfind
which will fail if there are too many files.Instead, you need to pass
"./*"
to the find command like this: