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:
FILES=./path/to/files/*
for f in $FILES
do
#delete files older than 7 days without using find
done
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.
This could be a PATH environment issue. As a commenter mentioned, you may want to try the full path in your cron.
Try
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:
/usr/bin/find
so rewrite your cron as: