Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
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.
If I ssh into a machine, run 'aptitude update' and 'aptitude dist-upgrade' and then close the Putty window before the update finishes, will it cancel the job? I should probably know this, but I want to make sure.
It depends on whether the command was designed to background itself or not.
When you close a session it sends a SIGHUP (hang up) to the processes. If they were designed to respond to that they'll shut down. Some processes are designed to ingore it.
However you can force it to ignore the SIGHUP and keep running in the background by starting it with the nohup command and ending with the ampersand (&). The nohup tells it NOT to accept a SIGHUP and the ampersand tells it to run in the background.
nohup aptitude update &
As to whether its wise to run "aptitude" that way I can't say as I've never done it. If it expects input at any point it will sit there until you kill the process as you won't be able to interact with it.
Example: doing "nohup vi /var/log/messages &" would not be a good idea. It would certainly start the vi session but since it wouldn't be associated with a terminal you couldn't do any edits and you'd have to kill the process to get rid of it.
FYI: When you do the background it tells you the PID of the process it starts.
you can foreground a backgrounded process though right? I think aptitude generally looks for the user to hit 'enter' at the end. I suppose I could use apt-get instead, which, if I recall correctly, doesn't.
Yep fg/bg are used to toggle foreground/background in many shells. I haven't really played with that much though.
Better yet you could use the "screen" command. This allows you to open a session on a terminal then close that terminal and later go back to the same session from that or any other terminal.
Some of the notes I had on screen usage (been awhile since I used it):
screen -list - Shows screen session names
screen -S <name> - Starts screen session and gives it <name> as name.
screen -x <pid> - Attaches to existing screen session with PID of <pid>.(12-Sep)
screen -x <name> - Attaches to existing screen session named <name>.(NO! 12-Sep)
Ctrl-A - Main command to use within screen. Selected options:
Ctrl-A ? - Gives a list of all options
Ctrl-A 0 - Goes to first window within a screen session.
Ctrl-A 1 - Goes to second window within a screen session.
Ctrl-A <n> - Goes to nth window within a screen session.
Doing exit from within a screen session will fall back to previous window.
Doing exit from all windows in screen session will terminate screen.
Closing window that has a screen session will leave it running and detached.
Sorry - My notes are written for me so are often a little confusing to others - I just cut and pasted.
It will work so long as you don't type "exit" or hit "Ctrl-D" to close the window. If you just close it with the little X at the top of the window it is OK.
Having said that:
I use PuTTY now but at the time was using a licensed version of OpenSSH on my Windows workstation. I see no reason that should make a difference but can see the possibility so didn't want you to think I'd led you astray.
You can test screen using the vi example. At worst you'll just have to kill the vi process. Once you've got the hang of it you can use it for aptitude.
When I used screen at that prior job I used it a lot and never had an issue once I'd figured it out. The notes were written to remind me of what I'd figured out.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.