Posted by: ranvijay | January 17, 2012

nohup not returning immediately

If a process is to be started in the background, generally the following command works:


nohup somecommand.sh &

But I observed that on some linux machines the above command waits for an ‘enter’ key to be pressed and doesn’t return immediately. This is annoying especially when the command is being run as part of some java code that is trying to start some remote process in background. The java process would simply hang in such a case.

To fix the problem, use the following command instead:


nohup somecommand.sh >>nohup.out 2>&1 &

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Categories

Follow

Get every new post delivered to your Inbox.