1

Assume that I am connected via SSH on a remote Ubuntu system. I want to execute a script there using nohup in case of potential connection drops and redirecting its log to a file. The command I run is

nohup bash myscript.sh > log.txt &

Then, the terminal prints the PID of the script and the message:

nohup ignoring input and redirecting stderr to stdout

The cursor freezes there and I am not able to execute other commands unless I exit the SSH session with Ctrl + D and relogin. I would prefer the SSH session to remain open and proceed to the next terminal prompt without the need to relogin. Is there any way to achieve this?

2
  • 2
    If you press Enter once do you get the prompt back?
    – roaima
    Aug 20, 2020 at 6:12
  • Yes. I was expecting that I had missed something trivial. Thanks.
    – mgus
    Aug 20, 2020 at 20:06

1 Answer 1

1

This command runs in the background as you'd expect. However, in this particular instance there's a race condition where the output message is written fractionally after the shell prompt.

The visual result is either that the shell prompt precedes the nohup message or that it's completely overwritten.

The practical result is that because the shell has written out its prompt it's ready for the next command. You can press Enter to generate a new prompt, or just type the next command in anyway.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.