Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then 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.
I am just wondering what happens to an SSH session when a power outage occurs on your client PC. If I am SSH'd in an running an script that takes a long time and your connection abruptly ends does the command finish running or cancel as soon as the connection stops? Does it depend on the type of connection?
Say I ssh in using:
Code:
ssh user@server
And once in I run the script test.sh, which takes ~10min to complete
Code:
./test.sh > ~/output
If my client PC is switched off 30sec into running this command is ~/output just filled with whatever was output up until 30sec?
"HUP" stands for "Hang Up," as in "(300 baud) teletype modems." The user switched-off the terminal or hung-up the phone ... or their cat did it, as the case may be. Or, you disconnected the SSH, or closed the window, or what have you. "Bottom line is, you went away." SIGHUP will be sent to all processes. Their ordinary response is to terminate.
The "nohup" command instructs the process to ignore this signal: to keep running.
Another option is to run your command inside "screen". With nohup, once you press enter, the process is "gone". By that I mean if it prompts you for something, pauses, etc., there's nothing you can do it interact with it again. With screen, you can disconnect and reconnect to the shell session that's running the script whenever you want. Of course the disadvantage of screen is that even when the process finishes, the screen session will still be sitting there waiting for you to close it, with nohup it'll just exit quietly.
Which method you should use depends on the process you're running. For the process in this thread, I agree that nohup is probably the better option, but there are many other instances where screen would be better suited.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.