LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   nohup query (https://www.linuxquestions.org/questions/linux-newbie-8/nohup-query-4175443759/)

vicky007aggrwal 01-02-2013 12:40 AM

nohup query
 
I have a JBOSS server process which i am running it using nohup command({nohup ./run.sh}), & same out put is getting printed to Jboss server.log as well,As i dont want the two log files having the same log entries then i tried the command nohup ./run.sh > ../log/server.log

Using this format log entries in server.log are getting printed twice.

Is there a better way by which i can redirect all output of nohup command to server.log without writing the same details twice to Jboss server log

please please suggest

tronayne 01-02-2013 08:15 AM

You're dealing with two output channels, stdout and stderr. The system automatically opens three channels for you, stdin (the keyboard, channel 0), stdout (the monitor, channel 1) and stderr (the monitor, channel 2). You can redirect channel 1 and channel 2; i.e., when you
Code:

prog > file
that puts standard output into file. When you do
Code:

prog 2> /dev/null
that puts standard error into /dev/null, the system black hole. By the same token, you can redirect standard error into one file and standard output into another file:
Code:

prog > file01 2> file02
Or (in you case you don't care about this) you can combine standard output and standard error into one
Code:

prog > file 2>&1
Now the above a valid for sh, ksh and BASH (the Bourne based shells) -- if you're using C-Shell, well, that last time I used that was about 30 years ago and I've forgotten how to do redirects with it (it's different), sorry.

If you just execute your program (without nohup) do you get double logs? If so, it might be a good idea to actually specify log files in the program -- open, write to, close -- to avoid duplication (or, maybe, tell JBoss to shut up, eh?). If that's not a problem, try the above and see what you get.

Hope this helps some.


All times are GMT -5. The time now is 03:15 AM.