LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 03-09-2004, 10:04 PM   #1
chakkerz
Member
 
Registered: Dec 2002
Location: Brisbane, Australia
Distribution: RedHat (RHEL, FC, CentOS), openSuSE, Mac OS X
Posts: 653

Rep: Reputation: 32
logging tar output


Hi All

I'm trying to backup some reasonably large filesystems. Due to constraints beyond my control i am doing this to a remote smbfs partition.

There is however a problem, i would like to get a log of all that happens whilst the tar is being generated, if tar reports any problems and so forth.

if [ "$DAY" = "$FULL_BACKUP_ON" ]; then
tar --exclude=/mnt/backup cjvf /mnt/backup/server1_$DATE.tar.bz2 /
else
find / -follow -depth -mtime 0 ! -type d ! -fstype smbfs | tar cjvT -> /mnt/backup/server1_$DATE.tar.bz2
fi

$DATE, $DAY and $FULL_BACKUP_ON are set / determined and the logic so far seems to be holding up

Never the less, how do i log the output generated by tar (as well as tar + find) ?

a > logfile.log was suggested, but that doesn't seem to do anything meaningful.
 
Old 03-09-2004, 11:07 PM   #2
michael@actrix
Member
 
Registered: Jul 2003
Distribution: OpenSUSE 11.4
Posts: 55
Blog Entries: 1

Rep: Reputation: 16
Processes have two common output streams, standard-output (stdout) and standard-error (stderr). Error messages are normally written to stderr.

The ">" redirect only captures stdout. In your example the stdout is already being redirected in the "|" pipelines you've set up.

For any process, stdout is its file descriptor number 1 (this relates to its internal file handle number), stderr is file descriptor number 2. The ">" redirect can have a number on the front of it, ">" is really short for "1>". To grab the standard error use "2>", for example:
Code:
    ls doesntexist 2> logfile
to do a whole bunch of commands you can perform them in a sub-shell and capture
its std error - a sub-shell can be started by using brackets:
Code:
  (
    find /baddir -name x
    ls doesntexist
  ) 2> logfile
Or use curly brackets, {}, if you don't want the overhead of running a sub-shell.

Note that the ordering of redirects can be important - these aren't the same:
Code:
ls goodfile badfile 2>&1 1> result
ls goodfile badfile 1> result 2>&1
Experiment and/or read to find out the difference.

See
Advanced Bash-Scripting Guide

And google for bash scripting FAQ and Howto.
 
Old 03-09-2004, 11:42 PM   #3
chakkerz
Member
 
Registered: Dec 2002
Location: Brisbane, Australia
Distribution: RedHat (RHEL, FC, CentOS), openSuSE, Mac OS X
Posts: 653

Original Poster
Rep: Reputation: 32
wow ... thanks ... i'll give that a shot
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Logging output from kdeinit Dyadya_Sam Linux - Newbie 3 06-05-2005 11:50 PM
Logging what Tar has done Equis Linux - General 1 02-21-2004 08:07 PM
Logging output from DUMP chrisk5527 Linux - General 2 01-26-2004 06:30 PM
Ipchains/Tables logging output going to std out? WeNdeL Linux - General 5 01-18-2003 03:29 AM
logging all keyboard input/output to a file div Linux - General 0 02-20-2001 05:29 AM


All times are GMT -5. The time now is 07:17 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration