Thursday, February 22, 2007

Starting a java daemon on Solaris

We were using Quartz as a scheduler to run our cron-like java programs on Solaris. Quartz gives us much more flexibility than the cron-tab, as we can add listeners and plug-ins.

Normally, when we exit a shell, all the programs that were started in the shell are terminated.
To avoid this, we made use of the 'nohup' command that keeps running the program even if the shell is closed. nohup = no-hang-up.

Also important thing to remember is that if the Std. input is kept open, then the shell does not exit. In the Java program, the main method automatically opens the Std input stream. Hence we need to close it. Here is the complete syntax.

nohup java com.domain.main_class <&- &

The ampersand at the end, starts the program in the background. nohup creates a file called nohup.log that contains the output to the standard stream.

No comments:

Post a Comment