{"id":18,"date":"2020-12-03T19:57:42","date_gmt":"2020-12-03T11:57:42","guid":{"rendered":"https:\/\/blog.luckytain.com\/?p=18"},"modified":"2020-12-03T20:15:38","modified_gmt":"2020-12-03T12:15:38","slug":"linux%e5%a6%82%e4%bd%95%e8%ae%a9%e6%ad%a3%e5%9c%a8%e8%bf%90%e8%a1%8c%e7%9a%84%e7%a8%8b%e5%ba%8f%e6%94%be%e5%88%b0%e5%90%8e%e5%8f%b0%e8%bf%90%e8%a1%8c%e8%bd%ac%e8%bd%bd","status":"publish","type":"post","link":"https:\/\/blog.luckytain.com\/?p=18","title":{"rendered":"Linux\u5982\u4f55\u8ba9\u6b63\u5728\u8fd0\u884c\u7684\u7a0b\u5e8f\u653e\u5230\u540e\u53f0\u8fd0\u884c(\u8f6c\u8f7d)"},"content":{"rendered":"<blockquote><p>\u6709\u65f6\u5019\u7528ssh\u5de5\u5177\u8fde\u63a5\u8fdc\u7a0b\u670d\u52a1\u5668\uff0c\u5728Linux\u8dd1\u4e00\u4e2a\u811a\u672c\uff0c\u7a81\u7136\u6709\u4e8b\uff0c\u8981\u5e26\u7740\u672c\u79bb\u5f00\uff0c\u5982\u679cssh\u8fde\u63a5\u65ad\u5f00\uff0c\u8fc7\u4e00\u4f1a\u811a\u672c\u6240\u5728\u7684\u8fdb\u7a0b\u4e5f\u4f1a\u88ab\u6740\u6b7b\uff0c\u8fd9\u65f6\u5019\u6211\u4eec\u53ef\u4ee5\u5c06\u5b83\u6302\u5728\u540e\u53f0\u8fd0\u884c\uff0c\u7136\u540e\u5c31\u53ef\u4ee5\u4ece\u5bb9\u7684\u5173\u6389ssh\u8fde\u63a5\u4e86\uff0c\u6f47\u6d12\u79bb\u5f00<\/p><\/blockquote>\n<p>\u5982\u4f55\u8ba9\u6b63\u5728\u8fd0\u884c\u7684\u8fdb\u7a0b\u653e\u5230\u540e\u53f0\u6267\u884c\uff1f \u9996\u5148\u4f7f\u7528ctrl + z\u6302\u8d77\u6b63\u5728\u8fd0\u884c\u7684\u8fdb\u7a0b\uff0c\u518d\u4f7f\u7528bg %1(\u4efb\u52a1\u6807\u53f7\u5177\u4f53\u53ef\u901a\u8fc7jobs -l\u67e5\u770b)\u653e\u7f6e\u5230\u540e\u53f0\u6267\u884c\uff0c\u518d\u6267\u884cdisown -h %1(\u4efb\u52a1\u6807\u53f7\u5177\u4f53\u53ef\u901a\u8fc7jobs -l\u67e5\u770b)\u5ffd\u7565HUP\u4fe1\u53f7,\u4ece\u800c\u8fdb\u7a0b\u53ef\u4ee5\u5728\u540e\u53f0\u6267\u884c<\/p>\n<p>&nbsp;<\/p>\n<h3>\u5177\u4f53\u6b65\u9aa4<\/h3>\n<p>1\u3001\u5c06\u811a\u672c\u653e\u7f6e\u5230\u524d\u53f0\u6267\u884c<\/p>\n<pre><code class=\"hljs coffeescript\">[root@al ~]<span class=\"hljs-comment\"># sh test.sh <\/span><\/code><\/pre>\n<p>2\u3001\u6267\u884cCtrl + z \u6302\u8d77\u73b0\u5728\u7684\u811a\u672c\uff0c\u5177\u4f53\u5982\u4e0b<\/p>\n<p><code><span class=\"hljs-selector-attr\">[1]<\/span>+ <span class=\"hljs-selector-tag\">Stopped<\/span> <span class=\"hljs-selector-tag\">sh<\/span> <span class=\"hljs-selector-tag\">test<\/span><span class=\"hljs-selector-class\">.sh<\/span><\/code><\/p>\n<p>&nbsp;<\/p>\n<p>3\u3001\u67e5\u770b\u6682\u505c\u7684\u811a\u672c<\/p>\n<p><code class=\"hljs css\"><\/code><\/p>\n<pre><code class=\"hljs css\"><span class=\"hljs-selector-attr\">[root@al ~]<\/span># <span class=\"hljs-selector-tag\">jobs<\/span> <span class=\"hljs-selector-tag\">-l<\/span>\r\n\r\n<span class=\"hljs-selector-attr\">[1]<\/span>+ 24609 <span class=\"hljs-selector-tag\">Stopped<\/span>                 <span class=\"hljs-selector-tag\">sh<\/span> <span class=\"hljs-selector-tag\">test<\/span><span class=\"hljs-selector-class\">.sh<\/span><\/code><\/pre>\n<p>4\u3001\u5c06\u811a\u672c\u653e\u7f6e\u5230\u540e\u53f0\u6267\u884c<\/p>\n<pre><code class=\"hljs css\"><span class=\"hljs-selector-attr\">[root@al ~]<\/span># <span class=\"hljs-selector-tag\">bg<\/span> 1\r\n\r\n<span class=\"hljs-selector-attr\">[1]<\/span>+ <span class=\"hljs-selector-tag\">sh<\/span> <span class=\"hljs-selector-tag\">test<\/span><span class=\"hljs-selector-class\">.sh<\/span> &amp;<\/code><\/pre>\n<p>5\u3001\u67e5\u770b\u653e\u5230\u540e\u53f0\u6267\u884c\u7684\u4efb\u52a1<\/p>\n<pre><code class=\"hljs bash\"><span class=\"hljs-built_in\">jobs<\/span> <span class=\"hljs-_\">-l<\/span>\r\n\r\n[1]+ 25487 Running                 sh test.sh &amp;<\/code><\/pre>\n<p>6\u3001\u8bbe\u7f6e\u5f53\u524djobs\u5ffd\u7565HUP\u4fe1\u53f7<\/p>\n<pre><code class=\"hljs apache\"><span class=\"hljs-attribute\">disown<\/span> -h <span class=\"hljs-number\">%1<\/span><\/code><\/pre>\n<p>\u5177\u4f53disown\u53c2\u6570\u53ef\u4f7f\u7528man\u67e5\u770b<\/p>\n<pre><code class=\"hljs coffeescript\">[root@al ~]<span class=\"hljs-comment\"># man disown <\/span><\/code><\/pre>\n<h3>\u5176\u4ed6\u5e38\u89c1\u7684\u5c06\u4efb\u52a1\u653e\u7f6e\u5230\u540e\u53f0\u7684\u65b9\u6cd5<\/h3>\n<ul>\n<li>nohup (\u5ffd\u7565HUP\u4fe1\u53f7)<\/li>\n<li>screen<\/li>\n<li>setid<\/li>\n<\/ul>\n<p><strong>viencoding.com\u7248\u6743\u6240\u6709\uff0c\u5141\u8bb8\u8f6c\u8f7d\uff0c\u4f46\u8f6c\u8f7d\u8bf7\u6ce8\u660e\u51fa\u5904\u548c\u539f\u6587\u94fe\u63a5:\u00a0<a href=\"https:\/\/viencoding.com\/article\/177\">https:\/\/viencoding.com\/article\/177<\/a><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6709\u65f6\u5019\u7528ssh\u5de5\u5177\u8fde\u63a5\u8fdc\u7a0b\u670d\u52a1\u5668\uff0c\u5728Linux\u8dd1\u4e00\u4e2a\u811a\u672c\uff0c\u7a81\u7136\u6709\u4e8b\uff0c\u8981\u5e26\u7740\u672c\u79bb\u5f00\uff0c\u5982\u679cssh\u8fde\u63a5\u65ad\u5f00\uff0c\u8fc7\u4e00\u4f1a\u811a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,11],"tags":[8,10,9],"class_list":["post-18","post","type-post","status-publish","format-standard","hentry","category-linux","category-11","tag-linux","tag-10","tag-9"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/blog.luckytain.com\/index.php?rest_route=\/wp\/v2\/posts\/18","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.luckytain.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.luckytain.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.luckytain.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.luckytain.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=18"}],"version-history":[{"count":0,"href":"https:\/\/blog.luckytain.com\/index.php?rest_route=\/wp\/v2\/posts\/18\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.luckytain.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=18"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.luckytain.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=18"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.luckytain.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=18"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}