简体   繁体   English

使用来自Windows cmd的cygwin在后台运行命令

[英]Running command in background using cygwin from Windows cmd

I use cygwin from my Windows command line, I've always done everything quite happily except being able to run something in the background (ie putting & at the end of a command). 我从我的Windows命令行使用cygwin,除了能够在后台运行某些东西(即在命令的末尾放置&之外,我总是非常愉快地完成所有事情。

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. 为了给你更多的上下文,我希望能够启动一个Mercurial Web服务器,并且仍然能够继续使用命令行窗口,甚至关闭它而不会杀死服务器。 For example: 例如:

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

Any workarounds to this? 对此有任何解决方法吗?

I had a similar problem running Apache, finally I used cygstart , it's like CMD start : 我在运行Apache时遇到了类似的问题,最后我使用了cygstart ,就像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 在这种情况下,由于--hide选项,它将运行Apache作为后台进程

Found the solution: 找到解决方案:

start <command> /B

start is a windows command, do a help start for more info start是一个windows命令, help start更多信息

Alternatively and for my case 或者和我的情况

hg serve --daemon

or 要么

hg serve -d

will do the trick 会做的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM