1

I have a cron job:

#!/bin/bash 
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:

/backup.sh: 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.

  • what are the permissions of the directory it is running in? – h3rrmiller Oct 24 '12 at 13:35
  • the backup.sh is running in 'sqlbackup' directory that has 777 or rwx for all. – dev.e.loper Oct 24 '12 at 13:37
2

you should use:

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

or

cd /full/path/to/

before you export the database

unless your cronjob looks like:

* * * * * cd /full/path/to && backup.sh

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.