Running command in background using cygwin from Wi

2019-04-11 22:08发布

问题:

I use cygwin from my Windows command line, I've always done everything quite happily except being able to run something in the background (i.e. putting & at the end of a command).

Just to give you more context, I want to be able to start a Mercurial web server and still be able to keep using the command line window and even closing it without killing the server. For example:

>hg serve &
listening at http://localhost:8000/ (bound to *:8000)
>echo "Still able to do this"

Any workarounds to this?

回答1:

I had a similar problem running Apache, finally I used cygstart, it's like CMD start:

cygstart --hide /c/apache/bin/httpd.exe

In this case, it will run Apache as an background proccess thanks to the --hide option



回答2:

Found the solution:

start <command> /B

start is a windows command, do a help start for more info

Alternatively and for my case

hg serve --daemon

or

hg serve -d

will do the trick



回答3:

'start' is an internal command of cmd.exe

You would have to use

cmd /c start COMMAND