How to route error to log file in unix


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to route error to log file in unix
# 1  
Old 07-30-2007
How to route error to log file in unix

Hey Every one

I have a find statement which find the files and deletes them

find /web/local/orderlink/batchmanaged01/scripts/SMOappLogs/log -name 'orderlink.log.*' -type f -mtime +$10-exec rm -f {} \;

This statement if finds a file at the given location it will delete the files but if it doesn't find files at the given path on the server then throws error saying

find: /web/local/orderlink/batchmanaged01/scripts/SMOappLogs/log: No such file or directory

I want to route this error to log file rather than displaying in the place where I executed the script

my log file declaration is
DIRNAME=`dirname $0`
LOGFILE=$DIRNAME/auto_purge.log

I want it to route the error to log file auto_purge.log located in the same directory structure

Thanks for the answers
Pinky
# 2  
Old 07-31-2007
Code:
find /web/local/orderlink/batchmanaged01/scripts/SMOappLogs/log -name 'orderlink.log.*' -type f -mtime +$10-exec rm -f {} \; 2>$LOGFILE

# 3  
Old 07-31-2007
Hi Thanks for hte answer it worked
But the problrm is I am able to see the error in log file but I am also seeing
as std output at the place where I ran the script
I want to route the error to log file and should not display it at the place where I ran
can you plz help me to get this done

Thanks
Pinky
# 4  
Old 07-31-2007
Not entirely sure what you mean - redirecting STDERR to the log should suffice:

Code:
$ find sdkasd -name "asdasd"
find: sdkasd: No such file or directory
$ find sdkasd -name "asdasd" 2>logfile
$ cat logfile
find: sdkasd: No such file or directory

Also; you have a typo in your find command - there should be a space between $10 and the -exec.

Cheers,
ZB
# 5  
Old 07-31-2007
Thanks it worked You guys are very helpful.


Regards
Pinky
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Print Error in Console and both Error & Output in Log file - UNIX

I am writing a shell script with 2 run time arguments. During the execution if i got any error, then it needs to redirected to a error file and in console. Also both error and output to be redirected to a log file. But i am facing the below error. #! /bin/sh errExit () { errMsg=`cat... (1 Reply)
Discussion started by: sarathy_a35
1 Replies

2. UNIX for Dummies Questions & Answers

No route to host - mail error

A linux box is supposed to emailing the results of backups to the windows exchange server, but nothing arrives. it never has, as the muppet who set up the Windows domain knew nothing about linux. I know only slightly more than that... pretty sure sendmail is the daemon running to handle mail. it... (0 Replies)
Discussion started by: Noewon
0 Replies

3. Shell Programming and Scripting

Capture all error message in Log file and send the Log file by email

Hi I have a requirement to write a script to capture all errors in a Logfile and send the file in email. If there is any error occurred the subject of email will be ERROR , If there are no error occurred the subject of email will be SUCCESS. So I created a Log file and put the Appropriate... (2 Replies)
Discussion started by: dgmm
2 Replies

4. Red Hat

Comment in static route file

Hi all, is it possible to add a comment starting with "#" (with vi for example) to the static route file in: /etc/sysconfig/network-scripts/route* Are you aware of any problems this can cause after a network restart? Thanks, Evan (1 Reply)
Discussion started by: Evan
1 Replies

5. Solaris

Error adding static route

Hi all i have a simple question here I'm kind of newbie on solaris development currently i'm trying to add static route to solaris environment and i got error, each time i add this static route to it btw this is my command : root@xxxxxx # ping 1.2.3.1 1.2.3.1 is alive echo ... (15 Replies)
Discussion started by: l33tbot_if
15 Replies

6. OS X (Apple)

What's The Easiest Route To Creating A Unix Executable File for Terminal?

I've seen the executable open in the application OmniOutliner, can I create an executable with this app? I'd like to be able to create the unix executable and insert it into terminal, but I'm not sure if the Omni app will allow me to create it. Any one have any ideas or possibly familiar with... (10 Replies)
Discussion started by: unimachead
10 Replies

7. UNIX for Dummies Questions & Answers

Route the logs to different file other than nohup.out

Hi guys Right now the standard out and standard err are going to nohup.out file I wanted to route to some other name specific files so that it will be easy to research the logs Example I have this line in my script nohup execute receiptLoaderStart & which is routing the logs to... (6 Replies)
Discussion started by: pinky
6 Replies

8. Programming

Error: No Route to host...urgent {socket() connection}

hello, I am doing Socket programming.. when I am establishing a socket connection using TCP protocol ...I am getting Error :: No route to host. at the client side during connect() call...........that it is returning -1. So I thing problem lies here......but what to do now... So for just... (6 Replies)
Discussion started by: arunchaudhary19
6 Replies

9. Shell Programming and Scripting

alert_oss.log oracle log file in hp-unix

Hi I have go this alert_oss.log that is basically capturing all the oracle errorlogs.Now the problem is that it is one huge file and to see log of some particular date i tried cat alert_oss.log | grep 'Mar 25 10:44:45 2007' > alert_25.txt is not giving me the required output. pls suggest ... (3 Replies)
Discussion started by: Assassin
3 Replies

10. Cybersecurity

UNIX error log

system administration utility has recently been installed at the SCO Openserver (UNIX) servers of our bank. While receiving the error log files of this utility, we have noted the following warning messages: <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> · ... (0 Replies)
Discussion started by: eysheikah
0 Replies
Login or Register to Ask a Question