I am writing a shell script to run a mysql backup as a cron job and am hitting an issue with the find command not being supported in the rackspace cloud sites cron environment. Any attempt to use the find command gives: /usr/bin/find: Permission denied

What alternatives are there to doing:

find *.gz -mtime +7 -delete

when the files are named like this :

gzip > /mnt/target03/rest-of-path/web/backups/DATABASENAME_`date "+%Y-%m-%d"`.gz


I was hoping that I could parse the file's date without using find in a loop, something like:

for f in $FILES
 #delete files older than 7 days without using find

  • Can you explain what you mean about it not being supported? Is it not installed? – Jeff Ferland Dec 20 '11 at 16:53
  • 2
    Try, /usr/bin/find path -name '*.gz' -mtime +7 -delete. Try setting your PATH in the script or using the full path. – Zoredache Dec 20 '11 at 16:59
  • Is that a RedHat system? If not, which distro? – Tim Dec 20 '11 at 18:14
  • By not supported I mean that the the cron user does not have permission to use the find command. I have updated the question. – codecowboy Dec 21 '11 at 9:20
  • Cloud sites is built on RedHat Enterprise server – codecowboy Dec 21 '11 at 9:28

I would suggest uploading your own copy of find if it doesn't exist there.

If that doesn't work, a Perl script using the File::Find module might be useful.

  • I will have to do it in PHP as I don't know perl but I'm guessing some kind of directory iteration and deletion is probably what I will end up doing. – codecowboy Dec 21 '11 at 9:29

This could be a PATH environment issue. As a commenter mentioned, you may want to try the full path in your cron.


whereis find
which find
locate find

To see if you can identify the full path to find.

On Red Hat systems, find is part of the findutils RPM and typically located at:


so rewrite your cron as:

/usr/bin/find *.gz -mtime +7 -delete
  • I have been told by rackspace that I simply will not have permission to run the find command. I have updated my question with the relevant error. – codecowboy Dec 21 '11 at 9:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.