I'm having a problem running a backup script through cron. The script runs perfectly 
from the command line, but when I run it through cron I end up with an empty file. 
This is presumably because the "mysqldump" is not recognized as a sh command (which 
it's not, understandably). What I need is a way to access the mysqldump app through 
crontab. 

Does anyone have any suggestions?

Following are all the scripts involved: 

------------------------------------------------------------------------
Perl script:
------------------------------------------------------------------------

#!/usr/bin/perl

($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime();
$mon++;
$year += 1900;
$date = "dbname_${year}_${mon}_${mday}_${min}";
`mysqldump -umysqluser -pmysqlpassword --flush-logs --lock-tables --databases dbname > 
/library/webserver/data/$date.sql`;

------------------------------------------------------------------------
crontab file:
------------------------------------------------------------------------
# use /bin/sh to run commands; override the default
# SHELL=/bin/sh

# run at 6:00 am everyday
0 6 * * * /library/webserver/data/usc_live_db.pl \ 1>& 
/library/webserver/data/crontab.log \ 2>& /library/webserver/data/crontab.err

# Or >> to append rather than replace

------------------------------------------------------------------------
crontab.err file:
------------------------------------------------------------------------
sh: mysqldump: command not found




Reply via email to