Re: Bash script questions.
- From: Handover Phist <jason@xxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 27 Mar 2007 06:09:36 GMT
Longfellow said "Bash script questions."
I've got rsync backing the partitions of one drive to another, and they
all work find. Now I want a shell script to run all the backups.
I began with mount checks:
if [ ! -d {some directory in backup partition} ]; then
mount -t ext2 {backup partition} /mnt/{backup mount}
fi
for each backup partition.
Then I list all the backup scripts with sleep 60 between each to let
things cool down a bit.
1) In each backup script: I've yet to trust the backup log to record
any error messages because I don't know whether or not '2>&1' works with
'>>' (append). I gather that the '2>&1' should be at the end of the
command rather than following or preceeding the append operator. Does
this work with append, and if so, where should it be?
Sounds like your doing it right
${COMMAND} 1>&2 ${LOGFILE} # Is at the end of the command.
If you want to record the error code then put
echo $? >> ${LOGFILE}
I'm going to trust that someone else will either back me up or tell me
I'm talking crap. I'm tired tonight.
2) In the master script, I want each backup script to be able to write
any problems to the log file. I gather that rsync gracefully exits with
an error message in any case, but I'm not certain. I don't want each
script to depend on the success of the previous one, so I'm not using
'&&' between scripts. What, if anything, should follow the script
executable?
$? == ${ERRMSG}
`man bash` for more info. $? is a wonderful thing, use liberally.
If all this gets to work dependably, it will become a cron job, so I
won't be around to intervene if things screw up.
Then look to making a quick and dirty e-mail script to mail off the log
files to you. In Slack I use `mail` from the Nail package. Most distros
have a `mail` command IME.
--
This signature intentionally left blank
http://www.websterscafe.com
.
- References:
- Bash script questions.
- From: Longfellow
- Bash script questions.
- Prev by Date: Bash script questions.
- Next by Date: Re: Bash script questions.
- Previous by thread: Bash script questions.
- Next by thread: Re: Bash script questions.
- Index(es):
Relevant Pages
|