Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I have a cron job:

fn=db.backup.$(date +%m-%d-%y).sql
mysqldump -uMyUsr -pMyPass --add-drop-table dbName> $fn
find ./ -name '*.Z' -type f -mtime +7 -exec rm -f {} \;

I get an error:

/ line 3: db.backup.10-24-12.sql: Permission denied
db.backup.10-24-12.sql: No such file or directory
find: ./conf: Permission denied
find: ./pd: Permission denied

It looks like whatever process is running cron doesn't have permissions to create a file or to run 'find' command.

share|improve this question
what are the permissions of the directory it is running in? – h3rrmiller Oct 24 '12 at 13:35
the is running in 'sqlbackup' directory that has 777 or rwx for all. – dev.e.loper Oct 24 '12 at 13:37

1 Answer 1

up vote 2 down vote accepted

you should use:

fn=/full/path/to/db.backup.$(date +%m-%d-%y).sql


cd /full/path/to/

before you export the database

unless your cronjob looks like:

* * * * * cd /full/path/to &&
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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