Re: Tape job notification | completion with mail command

2011-01-20 Thread Matt Shields
On Thu, Jan 20, 2011 at 2:23 PM, Richard Pieri wrote:

> On Jan 20, 2011, at 2:02 PM, stephen goldman wrote:
> >
> > Hello All,
> >I'm looking for a better way to work tape jobs. Seek input from
> others..
> >
> >The goal is to put the job in the background and receive an email when
> the job is complete.
>
> I think that you're on the right track but you don't put the tar in the
> background.  If you do that then you will need a second process watching for
> the first to complete.  What you really want to do is put a little shell
> script around the tar job, have it do the mailing, and background that.
>  Something like:
>
> #!/bin/sh
> tar -cvf /dev/nst0 files > /tmp/tar.log
> mail -s "Backup for `date`" sgold...@mit.edu < /tmp/tar.log
>
> --Rich P.
>
>
> ___
> Discuss mailing list
> Discuss@blu.org
> http://lists.blu.org/mailman/listinfo/discuss
>

You could take this a bit further and have it let you know in the subject if
it succeeded or not.

#!/bin/bash
tar -cvf /dev/nst0 files > /tmp/tar.log
if [ "$?" -ne "0" ]; then
  mail -s "Backup failed for `date`" sgold...@mit.edu < /tmp/tar.log
  exit 1
fi
mail -s "Backup succeeded for `date`" sgold...@mit.edu < /tmp/tar.log




-matt
___
Discuss mailing list
Discuss@blu.org
http://lists.blu.org/mailman/listinfo/discuss


Re: Tape job notification | completion with mail command

2011-01-20 Thread Richard Pieri
On Jan 20, 2011, at 2:02 PM, stephen goldman wrote:
> 
> Hello All,
>I'm looking for a better way to work tape jobs. Seek input from others..
> 
>The goal is to put the job in the background and receive an email when the 
> job is complete.

I think that you're on the right track but you don't put the tar in the 
background.  If you do that then you will need a second process watching for 
the first to complete.  What you really want to do is put a little shell script 
around the tar job, have it do the mailing, and background that.  Something 
like:

#!/bin/sh
tar -cvf /dev/nst0 files > /tmp/tar.log
mail -s "Backup for `date`" sgold...@mit.edu < /tmp/tar.log

--Rich P.


___
Discuss mailing list
Discuss@blu.org
http://lists.blu.org/mailman/listinfo/discuss


Re: Tape job notification | completion with mail command

2011-01-20 Thread john saylor
hi

On Thu, Jan 20, 2011 at 2:02 PM, stephen goldman  wrote:
>    The goal is to put the job in the background and receive an email when the 
> job is complete.

shouldn't you just write a shell script [and run it via cron]? it
could take arguments to be able to handle different files coming in or
different tape drives.

you can do all kinds of crazy stuff
- have it poll a directory and process any files that are there
- write a web page [with file upload (although the files may be too
big for that)]
- write a web service where you hit a certain URL with the right
arguments and it does it all for you

this seems to me like a programming problem. just spend enough time on
requirements ...

-- 
\js : "verbing weirds language." -calvin  [http://or8.net/~johns/]

___
Discuss mailing list
Discuss@blu.org
http://lists.blu.org/mailman/listinfo/discuss


RE: Tape job notification | completion with mail command

2011-01-20 Thread Palit, Nilanjan
> From: discuss-boun...@blu.org [mailto:discuss-boun...@blu.org] On Behalf Of 
> stephen goldman
> Sent: Thursday, January 20, 2011 2:02 PM


>How can I add  mail -s "tape job complete" sgold...@mit.edu 

> Typical job

> tar -cvf /dev/nst0 101201_80W2Y_236F.tgz > tape94a &

This might work:

$> (tar -cvf /dev/nst0 101201_80W2Y_236F.tgz > tape94a ; mail -s "tape job 
complete" sgold...@mit.edu) &

-Nilanjan


___
Discuss mailing list
Discuss@blu.org
http://lists.blu.org/mailman/listinfo/discuss


Re: Tape job notification | completion with mail command

2011-01-20 Thread Dan Ritter
On Thu, Jan 20, 2011 at 02:02:02PM -0500, stephen goldman wrote:
> Hello All,
> I'm looking for a better way to work tape jobs. Seek input from others..
> 
> The goal is to put the job in the background and receive an email when 
> the job is complete.
> 
> Should I be using "nohup" at the start of the command?
> 
> How can I add  mail -s "tape job complete" sgold...@mit.edu 
> 
> 
> Typical job
> 
> tar -cvf /dev/nst0 101201_80W2Y_236F.tgz > tape94a &

Write a script called tapejob. Perl is good for this, but not
actually necessary.

Pass in the relevant tape parameters and addresses; have good
defaults.

Separate the error output and use that as the body of your mail
message. Watch the errorlevel returned by the tar command; if it
isn't zero, you want to fire off an alert message -- different
subject? different recipients?

Now you say 
  tapejob -o tape94a -f 101201_80W2Y_236F.tgz -m sgold...@mit.edu &

And it all works nicely.

If you're going to fire these off by hand, 'screen' is an
excellent tool to have around. If not, 'cron' or 'at' might be
your friends.

-dsr-


-- 
http://tao.merseine.nu/~dsr/eula.html is hereby incorporated by reference.
You can't defend freedom by getting rid of it.
___
Discuss mailing list
Discuss@blu.org
http://lists.blu.org/mailman/listinfo/discuss