forked from lhcb/first-analysis-steps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
02-screen.html
81 lines (81 loc) · 5.79 KB
/
02-screen.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="generator" content="pandoc">
<title>Software Carpentry: First Steps in LHCb</title>
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" type="text/css" href="css/bootstrap/bootstrap.css" />
<link rel="stylesheet" type="text/css" href="css/bootstrap/bootstrap-theme.css" />
<link rel="stylesheet" type="text/css" href="css/swc.css" />
<link rel="alternate" type="application/rss+xml" title="Software Carpentry Blog" href="http://software-carpentry.org/feed.xml"/>
<meta charset="UTF-8" />
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body class="lesson">
<div class="container card">
<div class="banner">
<a href="http://software-carpentry.org" title="Software Carpentry">
<img alt="Software Carpentry banner" src="img/software-carpentry-banner.png" />
</a>
</div>
<div class="row">
<div class="col-md-10 col-md-offset-1">
<h1 class="title">First Steps in LHCb</h1>
<h2 class="subtitle">Using screen to keep things running</h2>
<div id="learning-objectives" class="objectives panel panel-warning">
<div class="panel-heading">
<h2><span class="glyphicon glyphicon-certificate"></span>Learning Objectives</h2>
</div>
<div class="panel-body">
<ul>
<li>Create a new <code>screen</code> session</li>
<li>Disconnect from a <code>screen</code> session</li>
<li>Reconnect to an existing <code>screen</code> session</li>
<li>End an existing <code>screen</code> session</li>
<li>Handling of Kerberos tokens</li>
</ul>
</div>
</div>
<p>Often we want to run a program for a long time on a computer we connected to via <code>ssh</code>, like the <code>lxplus</code> machines. The <code>screen</code> program allows you to keep programs running on the remote computer even if you disconnect from it. For example when putting your laptop to sleep or losing wifi.</p>
<p>Connect to <code>lxplus</code>:</p>
<pre class="sourceCode bash"><code class="sourceCode bash">$ <span class="kw">ssh</span> lxplus.cern.ch</code></pre>
<p>You can start <code>screen</code> by simply typing its name: <sub>~</sub> {.bash} $ screen <sub>~</sub></p>
<p>Once you do this it will look as if nothing has happened. However you now have a fresh terminal inside what is refered to as a "screen session". Let's type some commands that generate some output:</p>
<pre class="sourceCode bash"><code class="sourceCode bash">$ <span class="kw">uptime</span></code></pre>
<pre class="output"><code> 11:48:02 up 15 days, 20:36, 105 users, load average: 2.26, 2.10, 3.16</code></pre>
<pre class="sourceCode bash"><code class="sourceCode bash">$ <span class="kw">date</span></code></pre>
<pre class="output"><code>Thu Apr 16 11:48:32 CEST 2015</code></pre>
<p>To disconnect from this session press <code>Ctrl-a d</code>. We are now back to the terminal that we first started in. You can check that your <code>screen</code> session is still running by typing <code>screen -list</code>, which will list all active sessions:</p>
<pre class="sourceCode bash"><code class="sourceCode bash">$ <span class="kw">screen</span> -list</code></pre>
<pre class="output"><code>There is a screen on:
25593.pts-44.lxplus0234 (Detached)
1 Socket in /var/run/screen/S-thead.</code></pre>
<p>To reconnect to the session you use <code>screen -rD</code>. When there is just one session running (like now) then it will reconnect you to that session. Try it and you should see the date and time output by the <code>date</code> command we ran earlier.</p>
<p>When you have more than one session you need to provide the name of the session as an argument to <code>screen -rD</code>. The name of the above session is: <code>25593.pts-44.lxplus0234</code>. You can reconnect to it with:</p>
<pre class="sourceCode bash"><code class="sourceCode bash">$ <span class="kw">screen</span> -rD 25593.pts-44.lxplus0234</code></pre>
<p>To end a <code>screen</code> session you are currently connected to, simply press <code>Ctrl-d</code>. Just like you would to disconnect from a <code>ssh</code> session.</p>
<p>A <code>screen</code> session is tied to a specific computer. This means you need to remember which computer you connected to. Even if your <code>screen</code> session keeps running, you can only resume it from the same machine as you started it.</p>
<p>When connecting to <code>lxplus</code> you are assigned to a random computer, but you can find out its name with <code>hostname</code>:</p>
<pre class="sourceCode bash"><code class="sourceCode bash">$ <span class="kw">hostname</span></code></pre>
<pre class="output"><code>lxplus0081.cern.ch</code></pre>
<p>This tells you that the computer you are connected to is called <code>lxplus0081.cern.ch</code>. Later on you can re-connect to exactly this machine with:</p>
<pre class="sourceCode bash"><code class="sourceCode bash">$ <span class="kw">ssh</span> lxplus0081.cern.ch</code></pre>
</div>
</div>
<div class="footer">
<a class="label swc-blue-bg" href="http://software-carpentry.org">Software Carpentry</a>
<a class="label swc-blue-bg" href="https://github.com/swcarpentry/lesson-template">Source</a>
<a class="label swc-blue-bg" href="mailto:[email protected]">Contact</a>
<a class="label swc-blue-bg" href="LICENSE.html">License</a>
</div>
</div>
<!-- Javascript placed at the end of the document so the pages load faster -->
<script src="http://software-carpentry.org/v5/js/jquery-1.9.1.min.js"></script>
<script src="css/bootstrap/bootstrap-js/bootstrap.js"></script>
</body>
</html>