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.

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

1 Answer 1

3

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .