Re: script doesn't work when run as cron job

From: Nick Sinclair (null_device_at_NOFRILLS.ssl-mail.com)
Date: 10/13/04


Date: Wed, 13 Oct 2004 22:16:16 +1000

Let's see what "John L" <jl@lammtarra.fslife.co.uk> has up their dress.

>
>"Nick Sinclair" <null_device@NOFRILLS.ssl-mail.com> wrote in message news:uv1qm052cr49v91bn23jhqa3lv1ekbafs5@4ax.com...
>> Let's see what "John L" <jl@lammtarra.fslife.co.uk> has up their dress.
>>
>> >
>> >"Nick Sinclair" <null_device@NOFRILLS.ssl-mail.com> wrote in message news:cbbpm01894h6tuol3q9r8f8hmuf0153cql@4ax.com...
>> >> Hi all,
>> >> I have this script that I wrote to automate worstation backups on a Mitel
>> >> server (RedHat).
>> >>
>> >> It's a script that maintains mirrors of all shares on workstations in an
>> >> office by mounting a Windows "documents" share using 'samba' on the server
>> >> and then using 'rsync' to update the backup in the users home directory on
>> >> the server from from the mounted share.
>> >>
>> >> However, after upgrading from 5.6, using the collection of rpms, I notice
>> >> that the:
>> >>
>> >> grep "something" /etc/mtab && do something
>> >>
>> >> ... lines in the script now fail.
>> >>
>> >> When I run the script from the command line, it works fine.
>> >>
>> >> Q. It's real strange. Does anyone know what might be causing this, or maybe
>> >> can offer something for my epiphany?
>> >
>> >Normally, if a script that works from the command line fails
>> >as a cron job, it can be traced to one of the following:
>> >environment variables, permissions, or relative paths.
>> >
>> >Without checking the whole thing, rsync's exclude-file might fall
>> >into the third category.
>> >
>> >
>> >> $RSYNC -avz --exclude-from=exclude-file
>>
>> Thanks mate, I tried this:
>>
>> EXCLUDE-FILE=/usr/local/sbin/exclude-file
>> $RSYNC -avz --exclude-from="$EXCLUDE-FILE" \
>>
>> ...but no joy. Weird...
>>
>> Maybe someone can suggest something to isolate the problem?
>> Running out of ideas.
>>
>
>Call env in the script so you can see what is in the environment.

Ok, I have already done all these things, but I'll do 'em all again.

env > "$LOG_FILE"

PWD=/root
LOGNAME=root
SHLVL=2
SHELL=/bin/sh
HOME=/root
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/root/bin
_=/usr/bin/env

Ok, PWD is /root but I'm using all absolute paths. I wasn't for the
exclude-file option which you pointed out, but even with the change, still
nada.

>Set -x (or bash -x) so you can see what it is doing at each step.
>Or just round the rsync if you think that step is the problem
>(what happens to the * for example?).

It's all fine when run from CLI, but as a cron job, how do I get the debug
output using -x

>Cut the script down to just the failing part and debug that.

It is after all just the "grep" that fails, which is why I think it's
strange.

/dev/sig



Relevant Pages

  • Re: Files - 1 item not syncd
    ... John ... >you do that move the files back to the sync folder in ... Isolate further from there... ... >> I have a really annoying problem. ...
    (microsoft.public.pocketpc.activesync)
  • Re: Level of Cook at Cooks Illustrated
    ... Perhaps stand out a bit above the "too lazy to bother" guys? ... Naturally I read John Malloy's "Dress for Success" many, ...
    (rec.food.cooking)
  • Re: BEST COLLEGE MASCOT!
    ... A fat white guy in a dress? ... John M. Rogers ...
    (rec.sport.football.college)
  • Re: OT: Yahoo Messenger
    ... >>> Ya know, I always have a favorite dress, but that doesn't mean I'm ... > spamTHIS!.) ... Bill Chandler ... John ...
    (rec.music.makers.guitar.acoustic)
  • Re: Use of getchar
    ... > pointer within the string that the helpfile was talking about but I ... compileable example in order to isolate the problem. ... John Carson ...
    (comp.lang.cpp)