# How do I disown/detach a process from the Git Bash terminal that come with Git's Windows installer?

I would like to run commands from the terminal (mostly Python servers) and essentially daemonize them. I am running the MinGW terminal "Git Bash" that comes with the Windows installer for Git.

Things tried that do not work:

• $script.py & -> does not behave as expected • $ script.py & disown -> does not behave as expected

I would use bg, but my end-goal is to close the terminal after my servers are all running and not kill the processes.

-

I have no idea if this will work in bash in Windows, but bash provides a built-in command to "disown" a background process. After you've backgrounded the job with bg just run disown. By default it will disown the most recently bg-ed job, but you can also give it a job number if you have multiple background jobs.

-
Thank you, but like I stated in the original post, disown doesn't seem to be behaving as expected. Clearly, the problem is the Windows bash terminal; I was just hoping there were alternative ways to do this that I could try. –  burfl May 28 '13 at 18:10

This is a synthesis from my longer answer to a similar question in SO.

If your app logs to stdout/stderr, use:

cmd //c start cmd //k  "path\\to\\script-dir\\script.py"


If it logs to files, via sockets etc. and you do not need stdout/stderr, use:

cmd //c start //D "path\\to\\script-dir" script.py


In both cases you get a daemon like process which will survive when you close bash. In the first instance your script is hosted in a visible cmd.exe window.

Much more here.

-