I try to make a
init.d script which should start this java command:
java -cp ./:/opt/glassfish/domains/domain1/lib/*:/opt/glassfish/lib/* com.name.it.svcimpl.OrderRequestDispatcher &
& it starts as background process and this is fine. The problems are starting when you are trying to get it to the foreground:
 10119 user@server:$ fg 10119 -bash: fg: 10119: no such job
After you are pressing enter this happens:
+ Stopped java -cp ./:/opt/glassfish/domains/domain1/lib/*:/opt/glassfish/lib/* name.alcar.it.svcimpl.OrderRequestDispatcher
As you see there was no process like
10119 so why does it stop?
But the things getting much more difficult when the command is in a init.d bash script:
#!/bin/bash (cd /opt/glassfish/domains/domain1/applications/AS/WEB-INF/classes; java -cp ./:/opt/glassfish/domains/domain1/lib/*:/opt/glassfish/lib/* com.name.it.svcimpl.OrderRequestDispatcher &)
(Need to started under the path
Now my question as not java programmer is:
- Is it possible to run a java program in background with the option to foreground it from any terminal session?
As you can read it is really important to run it in background. Any user that are logged in should be able to put it to the foreground. The users are connecting with SSH to the terminal.