Yikes! Something strange in a cron job.

S. Dale Morrey sdalemorrey at gmail.com
Sat Feb 8 12:10:30 MST 2014

A long time ago I setup a low volume site and as a backup solution I
decided to have it email me a DB dump once a week.

Time passed and eventually I needed to move it to a bigger box.
Unfortunately I couldn't find any of the backups except for the ones taken
in the first few days as I was testing each component.

I logged in to see if something had crashed or gone wrong, but it's been
chugging along just fine this whole time.

I added a MAILTO in crontab so I get a "crons eye view" of why I'm not
getting my backup file and I get this error.

mysqldump: Got error: 1045: Access denied for user 'root'@'localhost'
(using password: NO) when trying to connect

What's strange about this error is that it's coming from a script called by
crontab, that runs perfectly fine as root.

Also username and password are set for root via a my.cnf file

I'm at a total loss here.  I'm pretty sure this means that cron isn't
setting whatever environment var is needed for mysql to read the my.cnf
file but I'm not sure what that would be.
Is there anyway to just tell crontab to export all of root's environment?


More information about the PLUG mailing list