• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Return from a shell script

 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a Ubuntu remote installation to which I log on using ssh. I have an application server that is running on this machine and I start it using a shell script as below:



What happens is that, when I close the terminal, the server shuts down. How do I make it such that even after I close the terminal, the server runs without shutting down?
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I appended calling the script with nohun command and it pretty much does what I want:



But now it seems to log everything to a file called nohup.out and I certainly do not want that. Any ideas?
 
Bartender
Posts: 1166
17
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So where do you want the output to go if not to nohup.out ? It has to go somewhere. You can redirect the output to a file name of your own choice or you can redirect to /dev/null if you just want to junk the output.
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have configured the location of the log file where my application logs everything when I start the server, but now it is being logged to nohup.out file which I really do not want.
 
Richard Tookey
Bartender
Posts: 1166
17
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Joe Harry wrote:I have configured the location of the log file where my application logs everything when I start the server, but now it is being logged to nohup.out file which I really do not want.



So pipe the output to 'logger' .


This will direct all stdout and stderr output to the system syslog ( on my Xubuntu system this is /var/log/syslog file ).
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Richard Tookey wrote:
So pipe the output to 'logger' .


This will direct all stdout and stderr output to the system syslog ( on my Xubuntu system this is /var/log/syslog file ).



This is not what I want. I do not want to send all the output to System log. Doing this would be crap for me!

I guess I might need to use another command other than nohup.
 
Richard Tookey
Bartender
Posts: 1166
17
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Joe Harry wrote:
This is not what I want. I do not want to send all the output to System log. Doing this would be crap for me!


Interesting. All you keep saying is what you don't want but never what you do want!


I guess I might need to use another command other than nohup.


The problem is not with 'nohup' but with you not knowing what you do what to do with the process 'stdout' and 'stderr' .
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I thought I mentioned in my post above that my application logs to a specific folder and I would like to retain that. Sorry if that was not clear enough!
 
Richard Tookey
Bartender
Posts: 1166
17
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are in effect two possible parts to stdout/stderr that can come from that 'java' command. The first is that from the Java application and whichever logging system you are using you should be able to define and install an appender to log ALL System.out and System.err to your standard log output. The second part is from the 'java' command before your Java program starts running. This cannot be simply diverted to your standard log file and you will need to handle that separately; how you do that is up to you but it should be simple enough to just append it, using the >> redirection, to your log file but probably without time and date annotation though. I don't see it as difficult to write a program to annotate this output with time and date since it is just a simple filter.

The first source of stdout/stderr is just a Java problem and not a Linux problem. The second is a Linux problem and not a Java problem.

Edit: after a little more thought it looks to be easy to prepend a time-stamp to each line of 'java' stdout and stderr by using 'awk' as a filter.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic