Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 03-09-2004, 11:04 PM   #1
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 /
find / -follow -depth -mtime 0 ! -type d ! -fstype smbfs | tar cjvT -> /mnt/backup/server1_$DATE.tar.bz2

$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-10-2004, 12:07 AM   #2
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:
    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:
    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:
ls goodfile badfile 2>&1 1> result
ls goodfile badfile 1> result 2>&1
Experiment and/or read to find out the difference.

Advanced Bash-Scripting Guide

And google for bash scripting FAQ and Howto.
Old 03-10-2004, 12:42 AM   #3
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


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-06-2005 12:50 AM
Logging what Tar has done Equis Linux - General 1 02-21-2004 09:07 PM
Logging output from DUMP chrisk5527 Linux - General 2 01-26-2004 07:30 PM
Ipchains/Tables logging output going to std out? WeNdeL Linux - General 5 01-18-2003 04:29 AM
logging all keyboard input/output to a file div Linux - General 0 02-20-2001 06:29 AM > Forums > Linux Forums > Linux - Newbie

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

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