everytime i launch a program, i cant use the console anymore...
hello,
My problem is, that everytime i launch a program, like a virtualbox image, the console launch it, but i cant use it anymore. I use ssh with putty remotely, and the problem is that if i close putty console, the program closes too... Can i do something to run the program independently of the console? or keep running after i close? if its possible, how i can i keep track of it when i open console again? |
To be able to use a console again after starting a command you can do two possible things:
1. You can append an ampersand (&) to the command which starts it in the background 2. You can start the command and then hit ^z (ctrl+z) to pause it and then run bg to background it As for running a program and having it continue after you close the console you can prepend your command with SIGHUP which lets the command ignore a SIGHUP when you log out. Regards, Alunduil |
alunduil,
I wonder if you meant to write "nohup" rather than "SIGHUP" ? `nohup` is the command to make applications ignore HUP signals, is it not? Also, for the OP: If you want to launch an app and totally disown (fully detach) the app from your terminal, bash has the `disown` keyword. A full usage of all the mentioned things might be like: Code:
$ nohup some_application & disown |
I did thanks for catching that. Don't know what I was thinking.
Regards, Alunduil |
If you need a console session to be maintained between logins, you can also use the screen program, which creates a virtual console that you can disconnect and connect to at will. Sort of like VNC for the console.
|
Hello
thank you all i have a mess betweek &, nohup, disown. & = background, but when i close terminal, background running and foreground running app's are killed nohup = ? disown = detaches app's from console, i can close it meanwhile, im installing screen. Looks like i can create as many consoles as i want, and switch between them. But i cant find a point; can i close the ssh shell where i launched screen? If the answer is "yes", if a login again, i guess simply by doing "#screen" again, i would be able to regain control of the running apps, right? thank you for the help, i will wait until clarification to start doing tests. |
Default keybinding to detach a screen session is CTRL-a + d. You can close your ssh session and the detached screen session will continue running. To re-attach do screen -r. If you have multiple screen sessions going that will list available sessions and you would do screen -r <session#>.
|
wow screen is great!
but i dont want to close the thread without understanding the nohup, &, disown commands. |
nohup = ignore the hangup signal. When you close your terminal session, it sends the hangup signal to running processes to close them. This prevents that.
& = runs the process in the background, free up your console to do other things. disown = disowns the process from its parent process. nohup makes the process ignore the hangup signal from the get go, disowning a process, AFAIK, prevents the signal from being sent. http://playingwithsid.blogspot.com/2...-commands.html |
The nohup is simply a script that grabs the SIGHUP handler before starting the command you want to run. The & is a bash language construct that backgrounds the process when it is executed by forking the process before executing it. I'm not familiar with the disown command but will do a little research and report back with anything I find.
Regards, Alunduil |
understood.
Guys, screen is a great trick, looks like there is a trick for every need in linux, and lot of times, we dont know them. Have you got a web with more useful tricks like that? other than that, problem solved. thanks. |
oh, and by the way,
i have another problem like this in windows CMD console. I know this is linux world, so i will just whisper lol, but, is there any similar command for windows? |
All times are GMT -5. The time now is 02:42 AM. |