Script works fine from CLI, but not when Cron'd

Jeremy Chadwick koitsu at FreeBSD.org
Tue Oct 7 09:32:27 UTC 2008


On Tue, Oct 07, 2008 at 10:20:32AM +0100, Marc Coyles wrote:
> I've got a script to backup my MySQL databases, which works absolutely
> fine from the command line, but when I add it in to root's cronjobs it
> always fails with "mysqldump: not found" - what am I doing wrong?

mysqldump is in /usr/local/bin, which $PATH does not contain when
running from a cronjob.  (PATH inside of cron has a very limited scope,
I believe it's /bin:/usr/bin).

Either set PATH to include /usr/local/bin, or just refer to the
fully-qualified path of mysqldump (/usr/local/bin/mysqldump).

-- 
| Jeremy Chadwick                                jdc at parodius.com |
| Parodius Networking                       http://www.parodius.com/ |
| UNIX Systems Administrator                  Mountain View, CA, USA |
| Making life hard for others since 1977.              PGP: 4BD6C0CB |



More information about the freebsd-questions mailing list