Running command in background using cygwin from Wi

2019-04-11 21:38发布

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?

3条回答
萌系小妹纸
2楼-- · 2019-04-11 22:10

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

查看更多
Juvenile、少年°
3楼-- · 2019-04-11 22:20

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

查看更多
做个烂人
4楼-- · 2019-04-11 22:29

'start' is an internal command of cmd.exe

You would have to use

cmd /c start COMMAND

查看更多
登录 后发表回答