On Thu, 10 Apr 2008 21:22:29 +1200
Roger Searle <[EMAIL PROTECTED]> wrote:

> Volker Kuhlmann wrote:
> > On Sun 06 Apr 2008 10:21:20 NZST +1200, Roger Searle wrote:
> >
> >   
> >> When run from the command line, they execute fine and I get the expected 
> >> file sizes of several hundred MB or a GB.  When run from cron, they 
> >> consistently create tar files of around 5 or 10 kb.
> >>     
> >
> > The cause of this sort of problem is almost always the same: When you
> > loig in interactively, you get a fully set up login shell and
> > environment. When cron runs a command, it switches to the correct user
> > ID but barely sets up 5 environment variables. The execution environment
> > of your programs from within cron is different to your interactive one.
> >
> > To investigate, run the command env from inside a script which is run by
> > cron, and redirect its output to a file. Compare with what you get
> > interactively. Pay special attention to PATH.
> >
> > Volker
> >   
> My user PATH:
> PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
> 
> The cron environment PATH:
> PATH=/usr/bin:/bin
> 
> Also:
> [EMAIL PROTECTED]:~$ whereis tar
> tar: /bin/tar
> 
> So tar is covered by either PATH.  However the following script will NOT 
> run via cron:
> /bin/tar -czvf /media/backup/backup-home-`date +%a-%d-%m-%y`.tgz  
> /home/roger
> 
> (the tgz file is created, but is always 9 or 10kb)
> 
> Perhaps that is because the shebang at the top of the script is:
> #!/bin/bash
> 
> and cron's environment has:
> SHELL=/bin/sh
> 
> but changing the shebang to #!/bin/sh does not get the script running 
> via cron.  Can anyone suggest what I need to do?
> 
> Cheers,
> Roger
> 
> 
> 
Which user's crontab are you running it from, and do they have privilege to 
access /home/roger. A tar tfz /media/backup... may give a bit more idea of 
what's going wrong by seeing what's saved. Also, you're doing a verbose backup. 
Why not save the output as a file list? It'll make it a lot easier to see what 
you've saved.

Steve

-- 
Steve Holdoway <[EMAIL PROTECTED]>

Reply via email to