File tree Expand file tree Collapse file tree 1 file changed +52
-0
lines changed Expand file tree Collapse file tree 1 file changed +52
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Keep processes running and closing SSH connection
2
+
3
+ The are several alternatives. Here we cover ` nohup ` and ` tmux ` .
4
+
5
+ ## Using ` nohup `
6
+
7
+ ```
8
+ $ nohup long-running-command &
9
+ ```
10
+ It logs ` stdout ` to ` nohup.log ` .
11
+
12
+
13
+ ## Using ` tmux `
14
+
15
+ 1 ) SSH into the remote machine.
16
+
17
+ 2 ) Install ` tmux ` :
18
+ ```
19
+ $ apt install tmux
20
+ ```
21
+
22
+ 3 ) Start ` tmux ` :
23
+ ```
24
+ $ tmux
25
+ ```
26
+
27
+ 4 ) Start the process you want inside the started ` tmux ` session.
28
+
29
+ 5 ) Leave/detach the ` tmux ` session by typing ` Ctrl+b ` and then ` d ` .
30
+
31
+ 6 ) You can now safely log off from the remote machine, your process will keep running inside ` tmux ` .
32
+
33
+ 7 ) When you come back again and want to check the status of your process you can attach to your tmux session using:
34
+ ```
35
+ $ tmux attach
36
+ ```
37
+
38
+ If you want to have multiple sessions running side-by-side, you should name each session using ` Ctrl+b ` and ` $ ` .
39
+
40
+ You can get a list of the currently running sessions using:
41
+ ```
42
+ $ tmux list-sessions
43
+ ```
44
+ or
45
+ ```
46
+ $ tmux ls
47
+ ```
48
+
49
+ To attach to a running session with use:
50
+ ```
51
+ $ tmux attach-session -t <session-name>
52
+ ```
You can’t perform that action at this time.
0 commit comments