Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Having to hit enter with nohup

Tags:

linux

I have a shell command like this

sudo nohup coffee -c -w *.coffee &
disown $!
wait

but when I run the shell scrit it says nohup: appending output to 'nohup.out' and makes me hit enter. How do I get around having to hit enter?

like image 943
Drew LeSueur Avatar asked Nov 06 '10 09:11

Drew LeSueur


2 Answers

8 year old thread, but I found that none of these answers really solve the issue in the question.

The message nohup: ignoring input and appending output to 'nohup.out' is piped through stderr (AFAIK), so in order to silence that message, all you have to do is to redirect stderr to /dev/null, like so:

nohup mycommand 2> /dev/null

However, if you additionally want to run this process in the background with &, you will find that (for bash at least), there will be a single line output of the job number and PID (e.g. [1] 27184). To avoid this, run the entire command in a subshell, like so:

(nohup my command 2> /dev/null &)

But if you're using this in a script, the former solution is sufficient.

like image 72
ning Avatar answered Oct 22 '22 11:10

ning


As far as I understand, you don't have to. The message is output to the console, but not added to your input buffer. Therefore you can just continue typing your commands in as if there were no message from nohup, the message will not interfere with your input.

Well, having to type not from the exact prompt position may be aesthetically not so pleasing.

like image 30
Vlad Avatar answered Oct 22 '22 09:10

Vlad