Redirecting program errors to both log and error file

Posted by Gnanam on Server Fault See other posts from Server Fault or by Gnanam
Published on 2010-04-01T09:01:58Z Indexed on 2010/04/01 9:03 UTC
Read the original article Hit count: 479

Filed under:
|
|

I've a Java standalone program scheduled to run as cron at every 10 minutes

I want to catch/write errors thrown by this Java program both in the log file and also as a separate error file (MyJavaStandalone.err).

I know the following commands:
Errors redirected to a separate file but not to log file

/usr/java/jdk1.6.0/bin/java MyJavaStandalone >> MyJavaStandalone.log 2>> MyJavaStandalone.err &

Both log and errors are redirected to the same log file, but errors alone are not written to a separate error file

/usr/java/jdk1.6.0/bin/java MyJavaStandalone >> MyJavaStandalone.log 2>&1 &

© Server Fault or respective owner

Related posts about linux

Related posts about scripting