On Fri, 09 Mar 2007 15:10:32 +1300
Roger Searle <[EMAIL PROTECTED]> wrote:

> so now that I have my backup script files ready and functional from
> either the command line or mouse click, I want cron running them, so am
> doing "crontab -e" - i understand the format of crontab.  i restart the
> cron daemon or ensure that at least 2 minutes will pass before schedule
> runs.  however when the scheduled time has passed the expected file will
> not have been created.   i will have mail in var/spool/mail/roger saying:
> 
> 
> /bin/sh: /windows/E/admin/backup-test.sh: /bin/bash: bad interpreter:
> Permission denied
> 
> alternatively i can use webmin to view the cron jobs and make it run
> "now" - the same error is returned.
> this will happen regardless of whether the cron job is run as roger or
> as root.
> 
> plenty of references to this error in google but nothing that seems
> helpful - particularly since it will run from the command line and the
> suggestions are usually to do with permissions.  root and users both
> have execute permission to the file.
> 
> any suggestions anyone?
> 
> Cheers,
> Roger

almost all errors in cron jobs are caused by the almost total lack of an 
environment that they're runnin in. Most painfully, the PATH isn't set in any 
useful way, which means that you either have to set it up at the start of your 
script, or you need to specify the absolute path of all commands.

For some reason - don't ask me why - I use the latter. For example, my generic 
backup script  has a block of declarations like

Tar="/bin/tar --create --verbose --ignore-failed-read"
Scp="/usr/bin/scp -P 2222 -q"
Rm="/bin/rm"
Find="/usr/bin/find"
Gzip="/bin/gzip"
MySQLDump="/usr/local/mysql/bin/mysqldump --all-databases --add-drop-table 
--flush-logs --extended-insert --create-options --disable-keys 
--single-transaction --quick"
PGDumpAll="/usr/local/pgsql/bin/pg_dumpall"
Mount="/bin/mount"
Umount="/bin/umount"
MkDir="/bin/mkdir"



and I usr $Tar tather than tar to run the command.


Steve

Reply via email to