[thelist] Backing up MySQL

Mark Kennedy mark at eurogamer.net
Tue Mar 2 06:16:04 CST 2004


>When I run it from the terminal, it all works fine. However If I make a 
>cron job to run this script, a file gets output (so the cronjob is 
>executing), but it's empty.

Two things to check:

1) Are you running the cron job as the same user as when you're running from the
terminal?

2) What environment variables are set when the cron job is run -- they might not
be the same as the ones set when running from a terminal window.  I don't
*think* your ~/.profile or .bash_profile (or whatever) is sourced when running a
job on cron because I had similar problems a while back.

A handy thing to do is to redirect stderr and stdout to a file somewhere, so you
get a record of what's going on.  mysqldump might be creating errors that you'll
never see.

If you stick

myscript.sh >> /path_somewhere/cron_error.log 2>&1 

as the cron job (or something like that) then both stderr and stdout will get
appended to the file cron_error.log and you might get a better idea of what's
going on.

Regards,

Mark




More information about the thelist mailing list