{"id":195,"date":"2010-09-10T16:49:29","date_gmt":"2010-09-10T08:49:29","guid":{"rendered":"http:\/\/www.ipcpu.com\/?p=195"},"modified":"2010-09-10T16:49:29","modified_gmt":"2010-09-10T08:49:29","slug":"linux-study-screen","status":"publish","type":"post","link":"https:\/\/c.ipcpu.com\/2010\/09\/linux-study-screen\/","title":{"rendered":"Linux\u5b66\u4e60\u7b14\u8bb0\u4e4bscreen\u547d\u4ee4\u7684\u4f7f\u7528"},"content":{"rendered":"

screen\u662f\u4e2a\u597d\u4e1c\u897f\uff0c\u8fd9\u51e0\u5929\u4e00\u76f4\u5728\u7528\u5b83\u3002<\/p>\n

\u5047\u5982\u9047\u5230\u4e00\u4e9b\u6bd4\u8f83\u8d39\u65f6\u95f4\u7684\u7a0b\u5e8f\uff0c\u4f46\u662f\u53c8\u4e0d\u80fd\u4e00\u76f4\u5f00\u7740\u7535\u8111\u89c2\u5bdf\u4ed6\uff0c\u603b\u8981\u4e0b\u73ed\u5173\u7535\u8111\u8d70\u4eba\u7684\u8bf4\uff0c\u8fd9\u65f6screen\u5c31\u6d3e\u4e0a\u7528\u573a\u4e86\u3002<\/p>\n

1.\u5982\u679c\u5728screenCRT\u4e2d\u5f00\u542f\u7a97\u53e3\uff0c\u7136\u540e\u8fd0\u884c\u4e00\u4e2a\u7a0b\u5e8f\uff0c\u5f53\u6ce8\u9500\u65f6\uff0c\u7a0b\u5e8f\u4f1a\u81ea\u52a8\u6bc1\u6389\u3002
\n2.\u4f7f\u7528nohup\u53ef\u4ee5\u89e3\u51b3\u6b64\u95ee\u9898\uff0c\u628a\u7a0b\u5e8f\u653e\u5230\u540e\u53f0\u8fd0\u884c\uff0c\u67e5\u770bnohup.out\u53ef\u4ee5\u67e5\u770b\u7a0b\u5e8f\u8fd0\u884c\u7684\u600e\u6837\u4e86\uff0c\u4f46\u662f\u4f7f\u7528nohup\u628a\u7a0b\u5e8f\u653e\u5230\u540e\u53f0\uff0c\u5c31\u518d\u4e5f\u65e0\u6cd5\u5207\u6362\u7a0b\u5e8f\u5230\u524d\u53f0\u4e86\uff0c\u800cscreen\u53ef\u4ee5\u3002<\/p>\n

\u4f7f\u7528\u65b9\u6cd5\uff1a<\/strong><\/p>\n

1.\u5b89\u88c5\uff0c<\/strong>centos\u9ed8\u8ba4\u6ca1\u6709\u5b89\u88c5\uff0c\u5b89\u88c5\u4e00\u4e0b\u3002<\/p>\n

2.\u8fdb\u5165screen\u3002<\/strong><\/p>\n

\u76f4\u63a5\u8f93\u5165screen\u56de\u8f66\u5373\u53ef\uff0c\u6b64\u65f6\u4f1a\u8fdb\u5165\u4e00\u4e2a\u65b0\u7684\u7ec8\u7aef\u3002\u53ef\u4ee5\u8fdb\u884c\u8981\u957f\u65f6\u95f4\u8fd0\u884c\u7684\u4f5c\u4e1a\u3002<\/p>\n

3.\u8fd4\u56de\u5230\u4e3b\u7ec8\u7aef\uff08screen\u4ecd\u7136\u5728\u540e\u53f0\u8fd0\u884c\uff09<\/strong>
\nCtrl+A \u7136\u540e\u6309D \u5c4f\u5e55\u663e\u793a[detached]<\/p>\n

4.\u8fd4\u56de\u5230screen<\/strong>
\nscreen -ls
\nThere is a screen on:
\n18245.pts-1.imobile-sv006-200 (Detached)
\n1 Socket in \/var\/run\/screen\/S-root.
\n\u53ef\u4ee5\u770b\u5230\u6240\u6709\u7684screen socket\uff0c\u4f7f\u7528screen -r 18245 \u5373\u53ef\u8fd4\u56de\u3002<\/span><\/p>\n

5.\u5f7b\u5e95\u9000\u51fascreen
\n<\/strong>screen\u7ec8\u7aef\u8f93\u5165exit\u3002\u5c4f\u5e55\u663e\u793a[screen is terminating]\u5373\u53ef<\/p>\n

6.\u5c4f\u5e55\u5171\u4eab\uff0c\u534f\u540c\u4f5c\u4e1a<\/strong><\/p>\n

\u5176\u4e2d\u4e00\u4e2a\u7528\u6237 screen -S\u00a0<\/span>ipcpu<\/span>\u00a0<\/span>\u4f7f\u7528\u547d\u540d\u7684socket\u4fbf\u4e8e\u8f93\u5165
\n\u53e6\u4e00\u4e2a\u7528\u6237 screen -x\u00a0<\/span>ipcpu<\/span>\u00a0<\/span>\u5373\u53ef\uff0c\u4e24\u4eba\u53ef\u4ee5\u534f\u540c\u64cd\u4f5c\uff0c\u4e00\u65b9\u7684\u64cd\u4f5c\u4f1a\u5728\u53e6\u4e00\u65b9\u5c4f\u5e55\u663e\u793a\u3002<\/p>\n

screen\u7684\u5176\u4ed6\u547d\u4ee4<\/strong>
\nCtrl-a ? \u5404\u529f\u80fd\u7684\u5e2e\u52a9\u6458\u8981
\nCtrl-a c \u521b\u5efa\u4e00\u4e2a\u65b0\u7684 window (\u7ec8\u7aef)
\nCtrl-a Ctrl-n \u548c Ctrl-a Ctrl-p \u5207\u6362\u5230\u4e0b\u4e00\u4e2a\u6216\u524d\u4e00\u4e2a window
\nCtrl-a Ctrl-N N \u4e3a 0 \u5230 9 \u7684\u6570\u5b57\uff0c\u7528\u6765\u5207\u6362\u5230\u76f8\u5bf9\u5e94\u7684 window
\nCtrl-a \u201d \u83b7\u53d6\u6240\u6709\u6b63\u5728\u8fd0\u884c\u7684 window \u7684\u53ef\u5bfc\u822a\u7684\u5217\u8868
\nCtrl-a a \u6e05\u695a\u9519\u8bef\u7684 Ctrl-a
\nCtrl-a Ctrl-d \u65ad\u5f00\u6240\u6709\u4f1a\u8bdd\uff0c\u4f1a\u8bdd\u4e2d\u6240\u6709\u4efb\u52a1\u8fd0\u884c\u4e8e\u540e\u53f0
\nCtrl-a x \u7528\u5bc6\u7801\u9501\u67f1 screen \u7ec8\u7aef<\/p>\n

===============================<\/p>\n

\u540e\u8bb0<\/p>\n

\u5728\u4f7f\u7528screen\u8fc7\u7a0b\u4e2d\uff0c\u7ecf\u5e38\u4f1a\u9047\u5230\u201c\u95ea\u5c4f\u201d\u7684\u95ee\u9898\uff0c\u8fd9\u662f\u53ef\u4ee5\u5173\u6389\u7684\u3002<\/p>\n

\u5feb\u901f\u5173\u6389<\/strong>\uff1a\u4e5f\u5c31\u662f\u5148\u8f93\u5165CTRL + a\uff0c\u518d\u8f93\u5165CTRL + g\u3002<\/p>\n

\u6c38\u4e45\u5173\u95ed<\/strong>\uff1a\u4fee\u6539\/etc\/screenrc \u52a0\u5165<\/em><\/p>\n

vbell off<\/strong><\/span><\/p>\n

\u5176\u5b9e\u8fd9\u4e0evi\u4e2d\u7684visualbell\u529f\u80fd\u5f88\u662f\u7c7b\u4f3c\u3002\u5728vi\u4e2d\u5173\u95ed\u95ea\u5c4f\uff0c\u662f\u4f7f\u7528:set novisualbell<\/strong>\u547d\u4ee4\u3002<\/p>\n

===============================
\n\u53c2\u8003\u8d44\u6599\uff1a
\n<\/strong>http:\/\/www.ibm.com\/developerworks\/cn\/linux\/l-cn-screen\/index.html<\/a>
\n
http:\/\/bbs.linuxtone.org\/viewthread.php?tid=160&highlight=screen<\/a><\/p>\n

\u8f6c\u8f7d\u8bf7\u6ce8\u660e\uff1aIPCPU-\u7f51\u7edc\u4e4b\u8def<\/a> » Linux\u5b66\u4e60\u7b14\u8bb0\u4e4bscreen\u547d\u4ee4\u7684\u4f7f\u7528<\/a><\/p>","protected":false},"excerpt":{"rendered":"

screen\u662f\u4e2a\u597d\u4e1c\u897f\uff0c\u8fd9\u51e0\u5929\u4e00\u76f4\u5728\u7528\u5b83\u3002 \u5047\u5982\u9047\u5230\u4e00\u4e9b\u6bd4\u8f83\u8d39\u65f6\u95f4\u7684\u7a0b\u5e8f\uff0c\u4f46\u662f\u53c8\u4e0d\u80fd\u4e00\u76f4\u5f00\u7740\u7535\u8111\u89c2\u5bdf\u4ed6\uff0c\u603b\u8981\u4e0b\u73ed\u5173\u7535\u8111\u8d70\u4eba\u7684\u8bf4\uff0c\u8fd9\u65f6screen\u5c31\u6d3e\u4e0a\u7528\u573a\u4e86\u3002 1.\u5982\u679c\u5728screenCRT\u4e2d\u5f00\u542f\u7a97\u53e3\uff0c\u7136\u540e\u8fd0\u884c\u4e00\u4e2a\u7a0b\u5e8f\uff0c\u5f53\u6ce8\u9500\u65f6\uff0c\u7a0b\u5e8f\u4f1a\u81ea\u52a8\u6bc1\u6389\u3002 2.\u4f7f\u7528nohup\u53ef\u4ee5\u89e3\u51b3\u6b64\u95ee\u9898\uff0c\u628a\u7a0b\u5e8f\u653e\u5230\u540e\u53f0\u8fd0\u884c\uff0c\u67e5\u770bnohup.out\u53ef\u4ee5\u67e5\u770b\u7a0b\u5e8f\u8fd0\u884c\u7684\u600e\u6837\u4e86\uff0c\u4f46\u662f\u4f7f\u7528nohup\u628a\u7a0b\u5e8f\u653e\u5230\u540e\u53f0\uff0c\u5c31\u518d\u4e5f\u65e0\u6cd5\u5207\u6362\u7a0b\u5e8f\u5230\u524d\u53f0\u4e86\uff0c\u800cscreen\u53ef\u4ee5\u3002 \u4f7f\u7528\u65b9\u6cd5\uff1a 1.\u5b89\u88c5\uff0ccentos\u9ed8\u8ba4\u6ca1\u6709\u5b89\u88c5\uff0c\u5b89\u88c5\u4e00\u4e0b\u3002 2.\u8fdb\u5165screen\u3002 \u76f4\u63a5\u8f93\u5165screen\u56de\u8f66\u5373\u53ef\uff0c\u6b64\u65f6\u4f1a\u8fdb\u5165\u4e00\u4e2a\u65b0\u7684\u7ec8\u7aef\u3002\u53ef\u4ee5\u8fdb\u884c\u8981\u957f\u65f6\u95f4\u8fd0\u884c\u7684\u4f5c\u4e1a\u3002 3.\u8fd4\u56de\u5230\u4e3b\u7ec8\u7aef\uff08screen\u4ecd\u7136\u5728\u540e\u53f0\u8fd0\u884c\uff09 Ctrl+A \u7136\u540e\u6309D \u5c4f\u5e55\u663e\u793a[detached] 4.\u8fd4\u56de\u5230screen screen -ls There is a screen on: 18245.pts-1.imobile-sv006-200 (Detached) 1 Socket in \/var\/run\/screen\/S-root. \u53ef\u4ee5\u770b\u5230\u6240\u6709\u7684screen socket\uff0c\u4f7f\u7528screen -r 18245 \u5373\u53ef\u8fd4\u56de\u3002 5.\u5f7b\u5e95\u9000\u51fascreen screen\u7ec8\u7aef\u8f93\u5165exit\u3002\u5c4f\u5e55\u663e\u793a[screen is terminating]\u5373\u53ef 6.\u5c4f\u5e55\u5171\u4eab\uff0c\u534f\u540c\u4f5c\u4e1a \u5176\u4e2d\u4e00\u4e2a\u7528\u6237 screen -S\u00a0ipcpu\u00a0\u4f7f\u7528\u547d\u540d\u7684socket\u4fbf\u4e8e\u8f93\u5165 \u53e6\u4e00\u4e2a\u7528\u6237 screen -x\u00a0ipcpu\u00a0\u5373\u53ef\uff0c\u4e24\u4eba\u53ef\u4ee5\u534f\u540c\u64cd\u4f5c\uff0c\u4e00\u65b9\u7684\u64cd\u4f5c\u4f1a\u5728\u53e6\u4e00\u65b9\u5c4f\u5e55\u663e\u793a\u3002 screen\u7684\u5176\u4ed6\u547d\u4ee4 Ctrl-a ? \u5404\u529f\u80fd\u7684\u5e2e\u52a9\u6458\u8981 Ctrl-a c \u521b\u5efa\u4e00\u4e2a\u65b0\u7684 window (\u7ec8\u7aef) Ctrl-a Ctrl-n \u548c Ctrl-a […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,13],"tags":[17,20],"_links":{"self":[{"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/posts\/195"}],"collection":[{"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/comments?post=195"}],"version-history":[{"count":0,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/posts\/195\/revisions"}],"wp:attachment":[{"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/media?parent=195"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/categories?post=195"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/tags?post=195"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}