Re: Script works fine from CLI, but not when Cron'd
On Tue, Oct 7, 2008 at 10:20 AM, Marc Coyles [EMAIL PROTECTED] 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? Things started from cron inherit a different PATH. Either add the appropriate directories to PATH or specify the full path to mysqldump. -- /JMS ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Script works fine from CLI, but not when Cron'd
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 Chadwickjdc 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 | ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Script works fine from CLI, but not when Cron'd
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@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED] 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 ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Script works fine from CLI, but not when Cron'd
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? Things started from cron inherit a different PATH. Either add the appropriate directories to PATH or specify the full path to mysqldump. In a script aimed to be run by cron, try to always use full path to the commands. It's the safest solution. Olivier ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]