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. |
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 its std error - a sub-shell can be started by using brackets: Code:
( Note that the ordering of redirects can be important - these aren't the same: Code:
ls goodfile badfile 2>&1 1> result See Advanced Bash-Scripting Guide And google for bash scripting FAQ and Howto. |
wow ... thanks ... i'll give that a shot
|
All times are GMT -5. The time now is 09:01 AM. |