[{"data":1,"prerenderedAt":435},["ShallowReactive",2],{"content-query-W0r7hS7r5c":3},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"tags":10,"body":11,"_type":429,"_id":430,"_source":431,"_file":432,"_stem":433,"_extension":434},"/tutorials/bash-screen","tutorials",false,"","Using screen in a Bash terminal","We can use the screen (Manual here) facility to keep jobs running on the background in a remote server.","bash",{"type":12,"children":13,"toc":427},"root",[14,42,49,62,94,98,104,123,128,258,270,273,279,306,309,315,335,358,371,394,397,403,421],{"type":15,"tag":16,"props":17,"children":18},"element","p",{},[19,22,29,31,40],{"type":20,"value":21},"text","We can use the ",{"type":15,"tag":23,"props":24,"children":26},"code",{"className":25},[],[27],{"type":20,"value":28},"screen",{"type":20,"value":30}," (",{"type":15,"tag":32,"props":33,"children":37},"a",{"href":34,"rel":35},"https://www.gnu.org/software/screen/manual/screen.html",[36],"nofollow",[38],{"type":20,"value":39},"Manual here",{"type":20,"value":41},") facility to keep jobs running on the background in a remote server.",{"type":15,"tag":43,"props":44,"children":46},"h4",{"id":45},"starting-a-new-screen-with-a-name",[47],{"type":20,"value":48},"Starting a new screen with a name",{"type":15,"tag":16,"props":50,"children":51},{},[52,54,60],{"type":20,"value":53},"The following creates a screen named ",{"type":15,"tag":23,"props":55,"children":57},{"className":56},[],[58],{"type":20,"value":59},"my_screen",{"type":20,"value":61},".",{"type":15,"tag":63,"props":64,"children":67},"pre",{"className":65,"code":66,"language":10,"meta":7,"style":7},"language-bash shiki shiki-themes github-light monokai monokai github-light monokai","screen -S my_screen\n",[68],{"type":15,"tag":23,"props":69,"children":70},{"__ignoreMap":7},[71],{"type":15,"tag":72,"props":73,"children":76},"span",{"class":74,"line":75},"line",1,[77,82,88],{"type":15,"tag":72,"props":78,"children":80},{"style":79},"--shiki-default:#6F42C1;--shiki-dark-mode:#A6E22E;--shiki-sky-dark-mode:#A6E22E;--shiki-light-mode:#6F42C1;--shiki-blue-mode:#A6E22E",[81],{"type":20,"value":28},{"type":15,"tag":72,"props":83,"children":85},{"style":84},"--shiki-default:#005CC5;--shiki-dark-mode:#AE81FF;--shiki-sky-dark-mode:#AE81FF;--shiki-light-mode:#005CC5;--shiki-blue-mode:#AE81FF",[86],{"type":20,"value":87}," -S",{"type":15,"tag":72,"props":89,"children":91},{"style":90},"--shiki-default:#032F62;--shiki-dark-mode:#E6DB74;--shiki-sky-dark-mode:#E6DB74;--shiki-light-mode:#032F62;--shiki-blue-mode:#E6DB74",[92],{"type":20,"value":93}," my_screen\n",{"type":15,"tag":95,"props":96,"children":97},"hr",{},[],{"type":15,"tag":43,"props":99,"children":101},{"id":100},"listing-all-available-screens",[102],{"type":20,"value":103},"Listing all available screens",{"type":15,"tag":63,"props":105,"children":107},{"className":65,"code":106,"language":10,"meta":7,"style":7},"screen -ls\n",[108],{"type":15,"tag":23,"props":109,"children":110},{"__ignoreMap":7},[111],{"type":15,"tag":72,"props":112,"children":113},{"class":74,"line":75},[114,118],{"type":15,"tag":72,"props":115,"children":116},{"style":79},[117],{"type":20,"value":28},{"type":15,"tag":72,"props":119,"children":120},{"style":84},[121],{"type":20,"value":122}," -ls\n",{"type":15,"tag":16,"props":124,"children":125},{},[126],{"type":20,"value":127},"Will output something similar to:",{"type":15,"tag":63,"props":129,"children":131},{"className":65,"code":130,"language":10,"meta":7,"style":7},"There are screens on:\n        455780.another_screen   (02/21/2024 07:24:46 PM)        (Detached)\n        455604.my_screen        (02/21/2024 07:24:41 PM)        (Attached)\n2 Sockets in /run/screen/S-mauricio.\n",[132],{"type":15,"tag":23,"props":133,"children":134},{"__ignoreMap":7},[135,158,198,234],{"type":15,"tag":72,"props":136,"children":137},{"class":74,"line":75},[138,143,148,153],{"type":15,"tag":72,"props":139,"children":140},{"style":79},[141],{"type":20,"value":142},"There",{"type":15,"tag":72,"props":144,"children":145},{"style":90},[146],{"type":20,"value":147}," are",{"type":15,"tag":72,"props":149,"children":150},{"style":90},[151],{"type":20,"value":152}," screens",{"type":15,"tag":72,"props":154,"children":155},{"style":90},[156],{"type":20,"value":157}," on:\n",{"type":15,"tag":72,"props":159,"children":161},{"class":74,"line":160},2,[162,167,173,178,183,188,193],{"type":15,"tag":72,"props":163,"children":164},{"style":79},[165],{"type":20,"value":166},"        455780.another_screen",{"type":15,"tag":72,"props":168,"children":170},{"style":169},"--shiki-default:#24292E;--shiki-dark-mode:#F8F8F2;--shiki-sky-dark-mode:#F8F8F2;--shiki-light-mode:#24292E;--shiki-blue-mode:#F8F8F2",[171],{"type":20,"value":172},"   (02/21/2024 ",{"type":15,"tag":72,"props":174,"children":175},{"style":90},[176],{"type":20,"value":177},"07:24:46",{"type":15,"tag":72,"props":179,"children":180},{"style":90},[181],{"type":20,"value":182}," PM",{"type":15,"tag":72,"props":184,"children":185},{"style":169},[186],{"type":20,"value":187},")        (",{"type":15,"tag":72,"props":189,"children":190},{"style":79},[191],{"type":20,"value":192},"Detached",{"type":15,"tag":72,"props":194,"children":195},{"style":169},[196],{"type":20,"value":197},")\n",{"type":15,"tag":72,"props":199,"children":201},{"class":74,"line":200},3,[202,207,212,217,221,225,230],{"type":15,"tag":72,"props":203,"children":204},{"style":79},[205],{"type":20,"value":206},"        455604.my_screen",{"type":15,"tag":72,"props":208,"children":209},{"style":169},[210],{"type":20,"value":211},"        (02/21/2024 ",{"type":15,"tag":72,"props":213,"children":214},{"style":90},[215],{"type":20,"value":216},"07:24:41",{"type":15,"tag":72,"props":218,"children":219},{"style":90},[220],{"type":20,"value":182},{"type":15,"tag":72,"props":222,"children":223},{"style":169},[224],{"type":20,"value":187},{"type":15,"tag":72,"props":226,"children":227},{"style":79},[228],{"type":20,"value":229},"Attached",{"type":15,"tag":72,"props":231,"children":232},{"style":169},[233],{"type":20,"value":197},{"type":15,"tag":72,"props":235,"children":237},{"class":74,"line":236},4,[238,243,248,253],{"type":15,"tag":72,"props":239,"children":240},{"style":79},[241],{"type":20,"value":242},"2",{"type":15,"tag":72,"props":244,"children":245},{"style":90},[246],{"type":20,"value":247}," Sockets",{"type":15,"tag":72,"props":249,"children":250},{"style":90},[251],{"type":20,"value":252}," in",{"type":15,"tag":72,"props":254,"children":255},{"style":90},[256],{"type":20,"value":257}," /run/screen/S-mauricio.\n",{"type":15,"tag":16,"props":259,"children":260},{},[261,263,268],{"type":20,"value":262},"Notice that ",{"type":15,"tag":23,"props":264,"children":266},{"className":265},[],[267],{"type":20,"value":59},{"type":20,"value":269}," is attached (currently active).",{"type":15,"tag":95,"props":271,"children":272},{},[],{"type":15,"tag":43,"props":274,"children":276},{"id":275},"detaching-from-a-screen",[277],{"type":20,"value":278},"Detaching from a screen",{"type":15,"tag":16,"props":280,"children":281},{},[282,284,290,292,298,299,305],{"type":20,"value":283},"You can detach a screen, and keep it running on the background, with ",{"type":15,"tag":23,"props":285,"children":287},{"className":286},[],[288],{"type":20,"value":289},"Ctrl",{"type":20,"value":291},"+",{"type":15,"tag":23,"props":293,"children":295},{"className":294},[],[296],{"type":20,"value":297},"A",{"type":20,"value":291},{"type":15,"tag":23,"props":300,"children":302},{"className":301},[],[303],{"type":20,"value":304},"D",{"type":20,"value":61},{"type":15,"tag":95,"props":307,"children":308},{},[],{"type":15,"tag":43,"props":310,"children":312},{"id":311},"reattaching-to-an-existing-screen",[313],{"type":20,"value":314},"Reattaching to an existing screen",{"type":15,"tag":16,"props":316,"children":317},{},[318,320,325,327,333],{"type":20,"value":319},"The following can be used to go back to a previously created screen named ",{"type":15,"tag":23,"props":321,"children":323},{"className":322},[],[324],{"type":20,"value":59},{"type":20,"value":326},".\n",{"type":15,"tag":328,"props":329,"children":330},"strong",{},[331],{"type":20,"value":332},"*Note",{"type":20,"value":334},": This will detach the screen from another existing session, if any.",{"type":15,"tag":63,"props":336,"children":338},{"className":65,"code":337,"language":10,"meta":7,"style":7},"screen -rd my_screen\n",[339],{"type":15,"tag":23,"props":340,"children":341},{"__ignoreMap":7},[342],{"type":15,"tag":72,"props":343,"children":344},{"class":74,"line":75},[345,349,354],{"type":15,"tag":72,"props":346,"children":347},{"style":79},[348],{"type":20,"value":28},{"type":15,"tag":72,"props":350,"children":351},{"style":84},[352],{"type":20,"value":353}," -rd",{"type":15,"tag":72,"props":355,"children":356},{"style":90},[357],{"type":20,"value":93},{"type":15,"tag":16,"props":359,"children":360},{},[361,363,369],{"type":20,"value":362},"If you do not give the screen a name when creating it, you can reattach to it using its id (see the ",{"type":15,"tag":23,"props":364,"children":366},{"className":365},[],[367],{"type":20,"value":368},"screen -ls",{"type":20,"value":370}," above to find the screen id):",{"type":15,"tag":63,"props":372,"children":374},{"className":65,"code":373,"language":10,"meta":7,"style":7},"screen -rd 455780\n",[375],{"type":15,"tag":23,"props":376,"children":377},{"__ignoreMap":7},[378],{"type":15,"tag":72,"props":379,"children":380},{"class":74,"line":75},[381,385,389],{"type":15,"tag":72,"props":382,"children":383},{"style":79},[384],{"type":20,"value":28},{"type":15,"tag":72,"props":386,"children":387},{"style":84},[388],{"type":20,"value":353},{"type":15,"tag":72,"props":390,"children":391},{"style":84},[392],{"type":20,"value":393}," 455780\n",{"type":15,"tag":95,"props":395,"children":396},{},[],{"type":15,"tag":43,"props":398,"children":400},{"id":399},"exiting-closing-a-screen",[401],{"type":20,"value":402},"Exiting (closing) a screen",{"type":15,"tag":16,"props":404,"children":405},{},[406,408,413,414,419],{"type":20,"value":407},"You can close a screen with ",{"type":15,"tag":23,"props":409,"children":411},{"className":410},[],[412],{"type":20,"value":289},{"type":20,"value":291},{"type":15,"tag":23,"props":415,"children":417},{"className":416},[],[418],{"type":20,"value":304},{"type":20,"value":420},". This will terminate the screen permanently, that is, you will not be able to reattach to it.",{"type":15,"tag":422,"props":423,"children":424},"style",{},[425],{"type":20,"value":426},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark-mode .shiki span {color: var(--shiki-dark-mode);background: var(--shiki-dark-mode-bg);font-style: var(--shiki-dark-mode-font-style);font-weight: var(--shiki-dark-mode-font-weight);text-decoration: var(--shiki-dark-mode-text-decoration);}html.dark-mode .shiki span {color: var(--shiki-dark-mode);background: var(--shiki-dark-mode-bg);font-style: var(--shiki-dark-mode-font-style);font-weight: var(--shiki-dark-mode-font-weight);text-decoration: var(--shiki-dark-mode-text-decoration);}html .sky-dark-mode .shiki span {color: var(--shiki-sky-dark-mode);background: var(--shiki-sky-dark-mode-bg);font-style: var(--shiki-sky-dark-mode-font-style);font-weight: var(--shiki-sky-dark-mode-font-weight);text-decoration: var(--shiki-sky-dark-mode-text-decoration);}html.sky-dark-mode .shiki span {color: var(--shiki-sky-dark-mode);background: var(--shiki-sky-dark-mode-bg);font-style: var(--shiki-sky-dark-mode-font-style);font-weight: var(--shiki-sky-dark-mode-font-weight);text-decoration: var(--shiki-sky-dark-mode-text-decoration);}html .light-mode .shiki span {color: var(--shiki-light-mode);background: var(--shiki-light-mode-bg);font-style: var(--shiki-light-mode-font-style);font-weight: var(--shiki-light-mode-font-weight);text-decoration: var(--shiki-light-mode-text-decoration);}html.light-mode .shiki span {color: var(--shiki-light-mode);background: var(--shiki-light-mode-bg);font-style: var(--shiki-light-mode-font-style);font-weight: var(--shiki-light-mode-font-weight);text-decoration: var(--shiki-light-mode-text-decoration);}html .blue-mode .shiki span {color: var(--shiki-blue-mode);background: var(--shiki-blue-mode-bg);font-style: var(--shiki-blue-mode-font-style);font-weight: var(--shiki-blue-mode-font-weight);text-decoration: var(--shiki-blue-mode-text-decoration);}html.blue-mode .shiki span {color: var(--shiki-blue-mode);background: var(--shiki-blue-mode-bg);font-style: var(--shiki-blue-mode-font-style);font-weight: var(--shiki-blue-mode-font-weight);text-decoration: var(--shiki-blue-mode-text-decoration);}",{"title":7,"searchDepth":160,"depth":160,"links":428},[],"markdown","content:tutorials:bash-screen.md","content","tutorials/bash-screen.md","tutorials/bash-screen","md",1793934184823]