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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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 '14 at 11:36
I can't for 7 hours. But yes, I will. – Toby Wisener Jul 30 '14 at 11:37
@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 '14 at 14:06
Time passes: it is time to move than answer to the answer section, and tick √ it. – richard Aug 13 '14 at 13:00
@mikeserv Can you provide your comment as an answer to this post? – Sebastian Sep 19 '14 at 13:50

Your Answer


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

Browse other questions tagged or ask your own question.