01-09-2008
A UNIX process has not one but *two* outputs by default: <stdout> and <stderr>
To capture them in a file you have to use two output redirections accordingly:
command 1> /some/file or
command > /some/file
will only redirect the file descriptor 1 (which is <stdout>). <stderr> will not be redirected and hence go to the default I/O device, in this case the screen of the terminal. To redirect the output on <stderr> too, issue:
command 1> /some/logfile 2>/some/errorfile
This will send the output to <stdout> to /some/logfile and the output to <stderr> to /some/errorfile. The same is true for cron (which is just another means to start processes) jobs. Probably you just haven't redirected the <stderr> output channel.
BEWARE:
Usually redirection is done in this casual way:
command >/path/to/logfile 2>&1
"2>&1" means: redirect file descriptor 2 ( = <stderr>) to where file descriptor 1 (<stdout>) points right now. The problem is, that these two file descriptors are still not the same and redirecting FD1 to somewhere else doesn't mean FD 2 will change too. A common pitfall is:
command 2>&1 >/path/to/logfile
which will first redirect FD 2 to where FD 1 points (perhaps the screen), then redirect FD 1 to a file. Most likely the intention was not this, but to redirect both to the same file, which would be achieved by the first example. To avoid any ambiguities better write it down this way, which doesn't depend on the order of the parts:
command 1>/path/to/logfile 2>/path/to/logfile
Hope this helps.
bakunin
10 More Discussions You Might Find Interesting
1. AIX
We are currently using AIX sysback for our backups and I have a script that kicks off the backups daily. We just had the problem with the tape filling up and hanging the script. I want to add a test to my script to listen for the End of Tape error or tape full error. I can't find any information... (0 Replies)
Discussion started by: daveisme
0 Replies
2. AIX
I've set sysback to run in the cron daily to backup my servers to a nim servers SAN storage. Every once and a while the backup process hangs and the backup doesn't complete. When I check the processes the sysback processes are still running hours after sysback would normally end. I don't see any... (1 Reply)
Discussion started by: daveisme
1 Replies
3. AIX
In smitty sysback I see there is are Offline Mirror backup and Snap Shot backup options and want to know how to use these backups without TSM. Or does anybody know where I can find information on setting up and preforming these type of backups and restores from the backups? (0 Replies)
Discussion started by: daveisme
0 Replies
4. Solaris
I have tried to compile the code on solaris which is
bash-3.00$ uname -a
SunOS zen 5.7 Generic_106541-37 sun4u sparc SUNW,Ultra-80
bash-3.00$ CC -V
CC: WorkShop Compilers 5.0 98/12/15 C++ 5.0
when I compile just a simple program,
int main()
{
long kk = 200;
int jj = kk;
return... (0 Replies)
Discussion started by: amit_27
0 Replies
5. AIX
Dear experts,
please help in this regard,
when i am trying to compile some files for 64 bit in AIX, iam getting this warning
"/usr/include/alloca.h", line 34.9: 1540-1401 (I) An unknown "pragma __alloca" is specified.
how to solve this warning , what is the significance of this please... (1 Reply)
Discussion started by: vin_pll
1 Replies
6. Emergency UNIX and Linux Support
I am trying to install the Sysback client (TSM for System Backup and Recovery) 6.1 on an LPAR running AIX 5.3. One of the filesets is failing to install. Here's what it says in the preview:
FAILURES:
tivoli.tsm.client.api.32bit 5.5.1.0 # TSM Client - Application Pro...
MISSING... (2 Replies)
Discussion started by: need2bageek
2 Replies
7. AIX
Is there a flag to send to sysback on the command line so it will return the estimated backup size and exit?
We're having issues with running to a second tape at a remote data center, and I want to alter the script to exit or add exclusions if the backup is over a certain size.
The other... (0 Replies)
Discussion started by: tommysalami
0 Replies
8. Shell Programming and Scripting
Hi Guys,
I am working on a shell script(main script) where in i have to call another script B and pass parameter to that script. I see that the shell script that is being called in the main script is throwing warnings/fatal errors. So i am just wondering how do i capture these and ask the script... (1 Reply)
Discussion started by: stunnerz_84
1 Replies
9. AIX
HELLO ALL
i have installed aix 6.2 , and install sysback 6.1 over Nim , and cinfigure it by Nim AND sysback smitty menu with create spot and lppsource and make TSM configration for that, i take image backup(installation image) successfully but when i want to restore this image , the boot cycle... (5 Replies)
Discussion started by: nancy_ghawanmeh
5 Replies
10. AIX
We used sysback to backup some older servers and now need to restore some of the directories within a file system. I've tried to use smitty sysback to list the content of the file system but there are over 3000 entries. I'm looking for a command that would allow me to list out the directories to... (2 Replies)
Discussion started by: daveisme
2 Replies
LOGSAVE(8) System Manager's Manual LOGSAVE(8)
NAME
logsave - save the output of a command in a logfile
SYNOPSIS
logsave [ -asv ] logfile cmd_prog [ ... ]
DESCRIPTION
The logsave program will execute cmd_prog with the specified argument(s), and save a copy of its output to logfile. If the containing
directory for logfile does not exist, logsave will accumulate the output in memory until it can be written out. A copy of the output will
also be written to standard output.
If cmd_prog is a single hyphen ('-'), then instead of executing a program, logsave will take its input from standard input and save it in
logfile
logsave is useful for saving the output of initial boot scripts until the /var partition is mounted, so the output can be written to
/var/log.
OPTIONS
-a This option will cause the output to be appended to logfile, instead of replacing its current contents.
-s This option will cause logsave to skip writing to the log file text which is bracketed with a control-A (ASCII 001 or Start of
Header) and control-B (ASCII 002 or Start of Text). This allows progress bar information to be visible to the user on the console,
while not being written to the log file.
-v This option will make logsave to be more verbose in its output to the user.
AUTHOR
Theodore Ts'o (tytso@mit.edu)
SEE ALSO
fsck(8)
E2fsprogs version 1.41.11 March 2010 LOGSAVE(8)