Search code examples
node.jsbashterminaloutputjobs

Sending a Node.js Grunt job to background


Usually appending & to the end of a command in a terminal will hide the output/redirect the standard output of the command.

I know that I could start a tmux session to achieve the same goal (namely, hiding the output, and using the same terminal window to execute more commands) but I'm curious why webpack's server will seemingly send the job to the background, then after a few seconds, no longer do so.

webpack dev server output

I looked at man bash and found this but it still doesn't quite answer my question (none of my other scripts that I use the redirection operator with behave like this)

Redirecting Standard Output and Standard Error

       Bash allows both the standard output (file descriptor 1) and the standard error output  (file
       descriptor 2) to be redirected to the file whose name is the expansion of word with this con-
       struct.

       There are two formats for redirecting standard output and standard error:

              &>word
       and
              >&word

       Of the two forms, the first is preferred.  This is semantically equivalent to

              >word 2>&1


Solution

  • Try this:

    nohup grunt serve &
    

    Recommended reading: Difference between nohup, disown and &