Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

For reference, I'm using phpseclib to control a remote SSH server using the 'root' account.

I have to start/stop a java process which is ran in the background. Stopping works fine with killall java and this is all I need for now, although when I run the server, I'm using:

(cd ./serv/; nohup java -classpath bin:deps/poi.jar:deps/netty.jar:deps/mysql.jar:deps/slf4j.jar:deps/slf4j-nop.jar:deps/jython.jar:log4j-1.2.15.jar: server.Server &)

As you can see, I am using the & operator for the second command inside the brackets. The command would execute correctly though the page would keep loading waiting for a return value/exit code? And it would eventually use up all the memory on my webhost.

The answer was that you need to manually direct the output of nohup:

Edit: Answer!!

(cd ./serv/; java -classpath bin:deps/poi.jar:deps/netty.jar:deps/mysql.jar:deps/slf4j.jar:deps/slf4j-nop.jar:deps/jython.jar:log4j-1.2.15.jar: server.Server >/tmp/test.out 2>&1 &)

Thanks to Mikeserv for the help.

share|improve this question
    
When you background a process you cutoff stdin/out unless it is explicitly redirected. Where does read/write to? –  mikeserv Jul 30 at 10:56
    
I thought nohup would write to nohup.out in the same directory? –  Toby Wisener Jul 30 at 11:06
3  
Toby - will you please move the answer part of the question to an answer? You should feel free to accept your own answer, by the way. –  mikeserv Jul 30 at 11:36
1  
I can't for 7 hours. But yes, I will. –  Toby Wisener Jul 30 at 11:37
2  
@TobyWisener, welcome to the site, please add the answer to answers and accept it you don't put the answer in the question, I recommend you to read this page: unix.stackexchange.com/tour –  Networker Jul 30 at 14:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.