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

Craig Butler craig001 at lerwick.hopto.org
Tue Oct 7 09:30:52 UTC 2008


On Tue, 2008-10-07 at 10:20 +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?
> 
> Script as follows:
> 
> #!/bin/sh
> USER=
> PASS=
> 
> mysqldump --opt -h localhost -u $USER -p$PASS horbury_dppd06
> >/home/horbury/backup_mysql/dppd06.sql
> 
> 
> And that's it...
> When run as root from CLI, works with no errors. When run from cron as
> root, get the "not found" problem.
> 
> 
> Marc A Coyles - Horbury School ICT Support Team
> Mbl: 07850 518106
> Land: 01924 282740 ext 730
> Helpdesk: 01924 282740 ext 2000
>  
> 
> 
> 
> _______________________________________________
> freebsd-questions at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"

When it is run from cron it is not picking up the shell .profile so PATH
is not set.  As mysqldump is sitting in a directory in one of the paths
(/usr/local/bin ??) 

Quick fix use full path details in the mysqldump line.

Or

Source in a .profile .... to set the paths.

Regards

Craig B




More information about the freebsd-questions mailing list