Shell script output redirection question


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell script output redirection question
# 1  
Old 02-21-2012
Shell script output redirection question

OS : AIX 6.1
Shell : Korn

in the url
https://forums.oracle.com/forums/thr...61463&tstart=0
I came across a crontab entry example

00 23 * * 1,3,5 <complete shell script path> 1> <log file> 2>&1

From googling , I gathered that
0 - stdin
1 - stdout
2 - stderr


I don't actually need 1> as shown below
/u01/darchive.sh 1>/u01/darchive.log 2>&1
Right?
I can just redirect both stdout and stderr to a file by using just 2>&1

/u01/darchive.sh > /u01/darchive.log 2>&1 # removed 1>

Right?
# 2  
Old 02-21-2012
Right.
# 3  
Old 02-21-2012
standard out (if any) will then show up in the crontab owners mail if I am not mistaken.
# 4  
Old 02-21-2012
@bsrepellant
You are mistaken.
polavan's script redirects any output which the script produces to a log file.

If the cron line itself is faulty (e.g. missing script), that error message will still appear in mail for the owner of the crontab.
# 5  
Old 02-21-2012
Quote:
Originally Posted by bsrepellant
standard out (if any) will then show up in the crontab owners mail if I am not mistaken.
Not in this case though as STDOUT has been redirected to the log file. If this was not done, then yes, STDOUT would be e-mailed to the owner of the process.
# 6  
Old 02-21-2012
Oops.
I didn't read the whole thing...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Output redirection of c binary file to a file in shell script is failing

I am struck up with a problem and that is with output redirection. I used all the ways for the redirection of the output of c binary to a file, still it is failing. Here are the different ways which I have used: ./a.out | tee -a /root/tmp.txt 2>&1 ./a.out | tee -a /root/tmp.txt 1>&1 ./a.out |... (2 Replies)
Discussion started by: Maya29988
2 Replies

2. Shell Programming and Scripting

Redirection of ls -l output

Hi I am making a script where i want to redirect the output of ls -l to a file Example #ls -l fil1.txt > /opt/temp/a.txt ac: No such file or directory I want to capture output of this command like here output is ac: No such file or directory can anyone help (4 Replies)
Discussion started by: anish19
4 Replies

3. Shell Programming and Scripting

Command output redirection in script not working

I need to count the number of lines in a .txt file and put it in a variable. I am using the following code #!/bin/bash count = $(wc -l "some file.txt" | awk '{print$1}') echo $count It is giving the following error. line3: count: command not foundWhat am I doing wrong here? :confused: (7 Replies)
Discussion started by: haritha.gorijav
7 Replies

4. Shell Programming and Scripting

output redirection to existing file question

So I have a existing file that I used the uniq command on and I need to save the output to the same file without changing the file name. I have tried $ uniq filename > filename then when I cat the file it then becomes blank like there is nothing inside. any help would be much appreciated... (0 Replies)
Discussion started by: drew211
0 Replies

5. Shell Programming and Scripting

Read input and output redirection filename within a script

Hello everyone, My requirement is that within a script I need to construct the command line exactly that it was invoked with. For example : sh a.sh arg1 arg2 arg3 < input.txt > output.txt Now within a.sh, I construct a file which has these contents " sh a.sh arg1 arg2 arg3 < input.txt >... (8 Replies)
Discussion started by: hedonist12
8 Replies

6. Shell Programming and Scripting

Redirection output

Hi there I have a script that runs but it outputs everything onto the screen instead of a file. I've tried using the > outputfile.txt however all it does is dump the output to the screen and creates an outputfile.txt but doesn't put anything in that file. Any help would be appreciated ... (6 Replies)
Discussion started by: kma07
6 Replies

7. Shell Programming and Scripting

Help with Output Redirection of a Unix Shell Script

Hi Guys, I have a script for which the stdout and stderr should be redirected to a log file, they should not be printed on the screen. Could you please let me know the procedure to redirect the output of the script to a log file. Thanks in advance. --- Aditya (5 Replies)
Discussion started by: chaditya
5 Replies

8. Shell Programming and Scripting

redirection and output

I'm redirecting the output of a command to a logfile, however, if the user is on a terminal I would also like the output to be displayed on the screen. tar tvf some_tarfile >Logfile if the user is on a term then have the output to the Logfile and also be displayed on the screen at the same... (2 Replies)
Discussion started by: nck
2 Replies

9. Shell Programming and Scripting

Unix shell output redirection help

Hi all, Actually i need to know whether there is any way to redirect the output of shell operations into any file without pipe . Actually my problem is , i run some command & its result is displayed on shell after some calculations on shell, so if i redirect its output to file, it is not... (5 Replies)
Discussion started by: sarbjit
5 Replies

10. Shell Programming and Scripting

Asking about shell script input output redirection

Hi, Can anyone please tell me what these lines do? ls >& outfile ls outfile 2>&1 Thanks. (1 Reply)
Discussion started by: trivektor
1 Replies
Login or Register to Ask a Question