The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
What's The Easiest Route To Creating A Unix Executable File for Terminal? unimachead OS X (Apple) 10 2 Weeks Ago 09:40 AM
Route the logs to different file other than nohup.out pinky UNIX for Dummies Questions & Answers 6 03-14-2008 08:48 AM
Error: No Route to host...urgent {socket() connection} arunchaudhary19 High Level Programming 6 10-30-2007 01:10 AM
Add Route on HP-UX v10.x, help. efrenba HP-UX 4 04-06-2007 05:26 AM
Error: Internal system error: Unable to initialize standard output file firkus UNIX for Dummies Questions & Answers 2 10-25-2005 12:23 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 07-30-2007
Registered User
 

Join Date: Jul 2007
Posts: 33
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
Reply With Quote
Forum Sponsor
  #2  
Old 07-31-2007
robotronic's Avatar
Can I play with madness?
 

Join Date: Apr 2002
Location: Italy
Posts: 370
Code:
find /web/local/orderlink/batchmanaged01/scripts/SMOappLogs/log -name 'orderlink.log.*' -type f -mtime +$10-exec rm -f {} \; 2>$LOGFILE
Reply With Quote
  #3  
Old 07-31-2007
Registered User
 

Join Date: Jul 2007
Posts: 33
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
Reply With Quote
  #4  
Old 07-31-2007
zazzybob's Avatar
Registered Geek
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
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
Reply With Quote
  #5  
Old 07-31-2007
Registered User
 

Join Date: Jul 2007
Posts: 33
Thanks it worked You guys are very helpful.


Regards
Pinky
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 02:03 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0