{"id":96,"date":"2020-01-22T19:33:47","date_gmt":"2020-01-22T19:33:47","guid":{"rendered":"https:\/\/ni.cmu.edu\/computing\/?post_type=ht_kb&#038;p=96"},"modified":"2020-01-24T12:59:46","modified_gmt":"2020-01-24T12:59:46","slug":"maintaining-connections","status":"publish","type":"ht_kb","link":"https:\/\/ni.cmu.edu\/computing\/knowledge-base\/maintaining-connections\/","title":{"rendered":"Maintaining Connections"},"content":{"rendered":"<p>When uses log onto remote severs as they do with the MIND cluster, often there are instances where they would like to logoff but still maintain running processes. The use of the following tools will allows users to maintain their sessions ( collections of windows ) and processes after they disconnect from the cluster.<\/p>\n<h3>Screen and tmux<\/h3>\n<p>Screen and tmux tools works on UNIX based operating systems such as Linux and MacOS. They allow users to use multiple windows and provides a way for a user to detach from a terminal session and then reattach to it at a later time. To be able to do this, the user has to be in a screen or tmux session. ( Just using the terminal won\u2019t allow you do this.) Whenever you are detached from the terminal session, the processes are killed but these tools allow the processes to continue when detached. You can reattach to the particular session at a later time and your active terminals will be as you left them.<\/p>\n<hr \/>\n<p>To start screen, type screen at the command prompt. Your original session will be detached and you will be brought to a new window.<\/p>\n<p>This shows details such as screen geometry and character set. The important part is that 2(bash) at the end. The 2 is the number of the currently displayed terminal window, and bash is the shell. Users can press crtl+A, then the number of the screen to which they wish to attach, or press <b> <em>Ctrl+A<\/em> <\/b>followed by a <b> <em>D<\/em> <\/b>to get a list of terminal windows available.<\/p>\n<p>Each screen can run any program contained on the cluster.<\/p>\n<p>To detach a screen and come back to it later&#8230;use the system above to start a window with Matlab or another program. Then issue the key <b> <em>Ctrl+A<\/em> <\/b>followed by a <strong><em>D<\/em><\/strong>. This will drop the user back to the bash prompt after detaching any session. The user may logout at this point.<\/p>\n<p>To reattach an existing session, login to the command prompt and type screen -ls. This will list all detached sessions.<\/p>\n<pre>[dpane@psych-o ~]$ screen -ls\r\nThere is a screen on:\r\n    8673.pts-6.psych-o    (Detached)\r\n1 Socket in \/var\/run\/screen\/S-dpane.<\/pre>\n<p>To reattach to that one session, I would type this at the bash prompt:<\/p>\n<pre>[dpane@psych-o ~]$ screen -r 8673.pts-6.psych-o<\/pre>\n<p>From there, it will return the session to the current login.<\/p>\n<hr \/>\n<div id=\"file-screen-md-readme\" class=\"Box-body readme blob js-code-block-container\">\n<article class=\"markdown-body entry-content p-5\">\n<h3>Screen Cheat Sheet<\/h3>\n<h6>Basics<\/h6>\n<ul>\n<li>ctrl a c -&gt; cre\u00adate new win\u00addow<\/li>\n<li>ctrl a A -&gt; set win\u00addow name<\/li>\n<li>ctrl a w -&gt; show all win\u00addow<\/li>\n<li>ctrl a 1|2|3|\u2026 -&gt; switch to win\u00addow n<\/li>\n<li>ctrl a &#8221; -&gt; choose win\u00addow<\/li>\n<li>ctrl a ctrl a -&gt; switch between win\u00addow<\/li>\n<li>ctrl a d -&gt; detach win\u00addow<\/li>\n<li>ctrl a ? -&gt; help<\/li>\n<li>ctrl a [ -&gt; start copy, move cur\u00adsor to the copy loca\u00adtion, press ENTER, select the chars, press ENTER to copy the selected char\u00adac\u00adters to the buffer<\/li>\n<li>ctrl a ] -&gt; paste from buffer<\/li>\n<\/ul>\n<h6>Starting screen<\/h6>\n<ul>\n<li>screen \u2013DR -&gt; list of detached screen<\/li>\n<li>screen \u2013r PID -&gt; attach detached screen ses\u00adsion<\/li>\n<li>screen \u2013dmS MySes\u00adsion -&gt; start a detached screen ses\u00adsion<\/li>\n<li>screen \u2013r MySes\u00adsion -&gt; attach screen ses\u00adsion with name MySession<\/li>\n<\/ul>\n<h6>Advanced<\/h6>\n<ul>\n<li>ctrl a S -&gt; cre\u00adate split screen<\/li>\n<li>ctrl a TAB -&gt; switch between split screens<\/li>\n<li>ctrl a Q -&gt; Kill all regions but the cur\u00adrent one.<\/li>\n<li>ctrl a X -&gt; remove active win\u00addow from split screen<\/li>\n<li>ctrl a O -&gt; logout active win\u00addow (dis\u00adable out\u00adput)<\/li>\n<li>ctrl a I -&gt; login active win\u00addow (enable output)<\/li>\n<\/ul>\n<\/article>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>When uses log onto remote severs as they do with the MIND cluster, often there are instances where they would like to logoff but still maintain running processes. The use of the following tools will allows users to maintain their sessions ( collections of windows ) and processes after they&#8230;<\/p>\n","protected":false},"author":1,"comment_status":"closed","ping_status":"closed","template":"","format":"standard","meta":{"footnotes":""},"ht-kb-category":[7],"ht-kb-tag":[],"class_list":["post-96","ht_kb","type-ht_kb","status-publish","format-standard","hentry","ht_kb_category-cluster"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ni.cmu.edu\/computing\/wp-json\/wp\/v2\/ht-kb\/96","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ni.cmu.edu\/computing\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/ni.cmu.edu\/computing\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/ni.cmu.edu\/computing\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ni.cmu.edu\/computing\/wp-json\/wp\/v2\/comments?post=96"}],"version-history":[{"count":7,"href":"https:\/\/ni.cmu.edu\/computing\/wp-json\/wp\/v2\/ht-kb\/96\/revisions"}],"predecessor-version":[{"id":248,"href":"https:\/\/ni.cmu.edu\/computing\/wp-json\/wp\/v2\/ht-kb\/96\/revisions\/248"}],"wp:attachment":[{"href":"https:\/\/ni.cmu.edu\/computing\/wp-json\/wp\/v2\/media?parent=96"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/ni.cmu.edu\/computing\/wp-json\/wp\/v2\/ht-kb-category?post=96"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/ni.cmu.edu\/computing\/wp-json\/wp\/v2\/ht-kb-tag?post=96"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}