{"id":1576,"date":"2015-04-09T23:18:43","date_gmt":"2015-04-09T14:18:43","guid":{"rendered":"http:\/\/tech.akat.info\/?p=1576"},"modified":"2015-04-09T23:20:27","modified_gmt":"2015-04-09T14:20:27","slug":"screen%e3%82%b3%e3%83%9e%e3%83%b3%e3%83%89","status":"publish","type":"post","link":"https:\/\/tech.akat.info\/?p=1576","title":{"rendered":"screen\u30b3\u30de\u30f3\u30c9"},"content":{"rendered":"<h1>\u6982\u8981<\/h1>\n<p>SSH\u304c\u7a81\u7136\u304d\u308c\u305f\u3068\u304d\u306b\u305d\u306e\u6bb5\u968e\u3067\u3057\u3066\u3044\u305f\u51e6\u7406\u306fSIGHUP\u30b7\u30b0\u30ca\u30eb\u3067\u7d42\u4e86\u3059\u308b<br \/>\n(SIGHUP\u30b7\u30b0\u30ca\u30eb\uff1a\u7aef\u672b\u7d42\u4e86\u6642\u306b\u767a\u751f\u3002\u5143\u6765\u306f\u30e2\u30c7\u30e0\u306e\u53d7\u8a71\u5668\u3092\u3042\u3052\u3066\u901a\u4fe1\u3092\u5207\u3063\u305f\u3053\u3068\u304b\u3089)<\/p>\n<h2>\u8a66\u3057\u3066\u307f\u308b\u3068SIGHUP\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u304c\u308f\u304b\u308b<\/h2>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nroot@hostname:\/home\/shimizu# cat \/usr\/local\/sbin\/sshtest.sh\r\n#!\/bin\/bash\r\n\r\n# EXIT\u30b7\u30b0\u30ca\u30eb\u3092trap\u3057\u3066\u7d42\u4e86\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u6307\u5b9a\u3059\u308b\u3002\r\ntrap &quot;echo '`basename $0`\u3092\u7d42\u4e86\u3057\u307e\u3059.'&quot; EXIT\r\n\r\n# \u4ed6\u306e\u30b7\u30b0\u30ca\u30eb\u3082trap\u3057\u3066\u304a\u304f\u3002\r\ntrap &quot;`echo 'SIGHUP\u3092trap\u3057\u307e\u3057\u305f' &gt; \/var\/log\/sshtest.log`&quot; 1\r\n\r\n# Ctrl+C\u3067\u7d42\u4e86\u3059\u308b\u30c6\u30b9\u30c8\u306e\u305f\u3081\u306bsleep\u3057\u3066\u304a\u304f\u3002\r\nsleep 100\r\n\r\nexit 0\r\nroot@hostname:\/home\/shimizu# \/usr\/local\/sbin\/sshtest.sh\r\n### \u5b9f\u884c\u4e2d\u306bSSH\u3092\u5207\u65ad\u3057\u3066\u3001\u518d\u5ea6\u63a5\u7d9a\u3059\u308b ###\r\nroot@hostname:\/home\/shimizu# cat \/var\/log\/sshtest.log\r\nSIGHUP\u3092trap\u3057\u307e\u3057\u305f\r\n<\/pre>\n<h1>\u3053\u308c\u3092\u9632\u3050\u305f\u3081\u306bscreen\u30b3\u30de\u30f3\u30c9\u3092\u5229\u7528\u3059\u308b<\/h1>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nroot@hostname:\/home\/shimizu# aptitude install screen\r\n\u4ee5\u4e0b\u306e\u65b0\u898f\u30d1\u30c3\u30b1\u30fc\u30b8\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u307e\u3059:\r\n  screen\r\n...\r\n\r\nroot@hostname:\/home\/shimizu# screen\r\n\r\nScreen version 4.01.00devel (GNU) 2-May-06\r\n\r\nCopyright (c) 2010 Juergen Weigert, Sadrul Habib Chowdhury\r\nCopyright (c) 2008, 2009 Juergen Weigert, Michael Schroeder, Micah Cowan, Sadrul Habib Chowdhury\r\nCopyright (c) 1993-2002, 2003, 2005, 2006, 2007 Juergen Weigert, Michael Schroeder\r\nCopyright (c) 1987 Oliver Laumann\r\n\r\nThis program is free software; you can redistribute it and\/or modify it under the terms of the GNU General Public License as published by the Free Software\r\nFoundation; either version 3, or (at your option) any later version.\r\n\r\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r\nFOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\r\n\r\nYou should have received a copy of the GNU General Public License along with this program (see the file COPYING); if not, see http:\/\/www.gnu.org\/licenses\/,\r\nor contact Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA.\r\n\r\nSend bugreports, fixes, enhancements, t-shirts, money, beer &amp; pizza to screen-devel@gnu.org\r\n\r\n\r\nCapabilities:\r\n+copy +remote-detach +power-detach +multi-attach +multi-user +font +color-256 +utf8 +rxvt +builtin-telnet\r\n\r\nroot@hostname:\/home\/shimizu# \/usr\/local\/sbin\/sshtest.sh\r\n### SSH\u3092\u4e2d\u65ad\u3057\u3066\u3001\u518d\u5ea6\u30ed\u30b0\u30a4\u30f3\u3059\u308b ###\r\n\r\nroot@hostname:\/home\/shimizu# ps afx\r\n...\r\n 6139 ?        Ss     0:00 SCREEN\r\n 6140 pts\/3    Ss     0:00  \\_ \/bin\/bash\r\n 6141 pts\/3    S+     0:00      \\_ \/bin\/bash \/usr\/local\/sbin\/sshtest.sh\r\n 6144 pts\/3    S+     0:00          \\_ sleep 100\r\n\r\n### screen\u306e\u72b6\u6cc1\u3092\u78ba\u8a8d\u3059\u308b ###\r\nroot@hostname:\/home\/shimizu# screen -ls\r\nThere is a screen on:\r\n        6139.pts-2.hostname     (2015\u5e7404\u670809\u65e5 23\u664211\u520650\u79d2)   (Detached)\r\n1 Socket in \/var\/run\/screen\/S-root.\r\n\r\n### atach\u3059\u308b\u3002detach\u3057\u3066\u3044\u308b\u9593\u3082\u51e6\u7406\u306f\u7d99\u7d9a\u3055\u308c\u3066\u3044\u305f ###\r\nroot@hostname:\/home\/shimizu# screen -r 6139.pts-2.hostname\r\n<\/pre>\n<p>[ctl]+[D]\u3067detach\u3067\u304d\u308b<br \/>\n\u307e\u305f[ctl]+[A]+[K]\u3067screen\u3092\u7d42\u4e86\u3059\u308b<\/p>\n<h1>\u53c2\u8003URL<\/h1>\n<p>\u30b7\u30b0\u30ca\u30eb\u3068 trap \u30b3\u30de\u30f3\u30c9<br \/>\nhttp:\/\/shellscript.sunone.me\/signal_and_trap.html<br \/>\nssh\u5207\u65ad\u5f8c\u306e\u6319\u52d5\u306b\u3064\u3044\u3066<br \/>\nhttps:\/\/teratail.com\/questions\/5771<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u8981 SSH\u304c\u7a81\u7136\u304d\u308c\u305f\u3068\u304d\u306b\u305d\u306e\u6bb5\u968e\u3067\u3057\u3066\u3044\u305f\u51e6\u7406\u306fSIGHUP\u30b7\u30b0\u30ca\u30eb\u3067\u7d42\u4e86\u3059\u308b (SIGHUP\u30b7\u30b0\u30ca\u30eb\uff1a\u7aef\u672b\u7d42\u4e86\u6642\u306b\u767a\u751f\u3002\u5143\u6765\u306f\u30e2\u30c7\u30e0\u306e\u53d7\u8a71\u5668\u3092\u3042\u3052\u3066\u901a\u4fe1\u3092\u5207\u3063\u305f\u3053\u3068\u304b\u3089) \u8a66\u3057\u3066\u307f\u308b\u3068SIGHUP\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u304c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[8],"tags":[],"_links":{"self":[{"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/posts\/1576"}],"collection":[{"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tech.akat.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1576"}],"version-history":[{"count":5,"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/posts\/1576\/revisions"}],"predecessor-version":[{"id":1581,"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/posts\/1576\/revisions\/1581"}],"wp:attachment":[{"href":"https:\/\/tech.akat.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1576"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tech.akat.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1576"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tech.akat.info\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1576"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}