If I'm running a program in bash, I can suspend it by pressing Ctrl+Z. If I want to leave the program running, I can then use the bg
command. Is there some way to directly put the program in the background, without having to type bg
?
Clarification: I want to put the program in the background when it is already running, without suspending it.
I do not think it is possible to move a running program to background(while the process is still in running state).
However there is an application called GNU-Screen,using which you can run any number of console-based applications--interactive command shells, curses-based applications, text editors, etc.--within a single terminal.
Here is a nice tutorial on GNU-Screen.
Note that it does not do exactly what you asked,but serves the purpose anyway.
Example:
Here is the implementation of what you asked using GNU-Screen.
screen
You will get details about the software.Press return.
vlc
. It will start the process within that window.To my best of knowledge you could run it and then append an & after it like this:
myprogram &
I may be very wrong here however.
[EDIT]: Taking a closer look to this, if you run the above, the application will close when you close the terminal. If you would like the application to run in the background, then, as far as I know, the application needs to be written in such a way that supports daemon behavior.
[EDIT 2]:
nohup command &
appears to be closer to what you want to achieve. Nohup will allow an application to run, and will both ignore its input and redirect its output to a file callednohup.out
in the current directory.This may not a real answer. I wonder what the different of Bash between Ubuntu with MSYS.
I running MSYS and when i run
Application/Chrome &
, it immediately go to background process. I can use the MSYS bash as next prompt start blinking.And are this questions Move running program to background with similar intents?