[SOLVED] everytime i launch a program, i cant use the console anymore...
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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
Now, the application has been totally detached from the tty it was started from.
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.
& = 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#>.
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.
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.
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?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.