Re: [Nolug] Bash backup script help

From: Chris Jones <techmaster_at_gmail.com>
Date: Sat, 23 Jun 2007 14:46:42 -0500
Message-ID: <945e1c690706231246p5e7e6fe7w5b5a3b9cc116980f@mail.gmail.com>

One more thing I thought of... I set this script up as a crontab to run at
11pm every night. I'm thinking of making another script as a watchdog, to
run at maybe 1am, to make sure it's running. Here's what I've got so far,
and the output it gives me:

/etc# /etc/init.d/vmware status | grep "VMware Server"
At least one instance of VMware Server is still running.

How can I test that in an if statement?

On 6/23/07, B. Estrade <estrabd@gmail.com> wrote:
>
> doh! sorry;
>
> > "||" executes the second command only if the first one succeeds.
>
> I meant "only if the first one FAILS". Sorry.
>
> B
>
> On 6/23/07, B. Estrade <estrabd@gmail.com> wrote:
> > Chris,
> >
> > You could also use "&&" and "||"
> >
> > % cmd1 ... && cmd2
> > % cmd1 ... || cmd2
> >
> > "&&" executes the second command only if the one before it returns a
> > successful exit status; "||" executes the second command only if the
> > first one succeeds.
> >
> > Real world example; initially the directory 'test' does not exist:
> >
> > $ cd test 2> /dev/null || (mkdir test && touch test/test.dat)
> >
> > Or in your case:
> >
> > #!/bin/sh
> > tar .. || exit 1
> > echo hi # this will not print if tar fails
> >
> > B
> >
> > On 6/22/07, Chris Jones <techmaster@gmail.com> wrote:
> > > Thanks, I just figured it out before I checked my email. ;) Works
> great as
> > > far as I can tell, now I've just got to wait till this weekend to try
> > > shutting down vmware and backing it up.
> > >
> > >
> > > On 6/22/07, -ray <ray@ops.selu.edu> wrote:
> > > > On Fri, 22 Jun 2007, Chris Jones wrote:
> > > >
> > > > > The functionality I'm wanting to add to it, is after the TAR/GZIP
> > > operation,
> > > > > I want it to know if the tar command completed successfully or
> with
> > > errors.
> > > > > If there were errors, then skip the deletion process. The
> skipping part
> > > is
> > > > > easy, but I guess the main thing I'm wondering is how do I test
> whether
> > > the
> > > > > tar command ran successfully? I remember in DOS, after you run a
> > > command,
> > > > > you can test it with "IF ERRORLEVEL=0" and if that returns true
> then you
> > > > > know the command completed successfully. What's the unix
> equivalent?
> > > >
> > > > It's similar in unix, using the $? variable. Most commands will
> exit
> > > > non-zero status if there's a problem, and exit zero status if
> there's no
> > > > problem. Based on this, run this code immediately after the tar
> command:
> > > >
> > > > if [ $? != 0 ]; then
> > > > echo "tar exitted non-zero. Let's not delete"
> > > > exit 1
> > > > fi
> > > >
> > > > ray
> > > > --
> > > >
> > > =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> > > > Ray DeJean
> > > http://www.r-a-y.org
> > > > Systems Engineer Southeastern
> > > Louisiana University
> > > > IBM Certified Specialist AIX Administration, AIX
> Support
> > > >
> > > =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> > > >
> > > > ___________________
> > > > Nolug mailing list
> > > > nolug@nolug.org
> > > >
> > >
> > >
> >
> >
> > --
> > 225.578.1920
> > AIM: bz743
> > http://www.loni.org/
> > estrabd@lsu.edu
> > estrabd@gmail.com
> >
>
>
> --
> 225.578.1920
> AIM: bz743
> http://www.loni.org/
> estrabd@lsu.edu
> estrabd@gmail.com
> ___________________
> Nolug mailing list
> nolug@nolug.org
>

___________________
Nolug mailing list
nolug@nolug.org
Received on 06/23/07

This archive was generated by hypermail 2.2.0 : 12/19/08 EST