Tutorial: Linux tips: Several ways to keep your process running reliably in the background
Search the Internet a bit, a lot of methods, choose the most popular screen
Command reference: Http://man.linuxde.net/screen
1. Installation
Install Screen ... [Email protected]:~# Screen-list lists all sessions there is a screens on: 1883. pts-0. XKFX ( //2018: (attached)1 in/var/run/screen/s-root.
2. Basic operation
For example, I'm going to shut down my Computer (SSH) for a nap, and I want the mining program to continue running:
[Email protected]:~# screen-ls
There is a screens on:
1883.PTS-0.XKFX (03/04/2018 12:06:14 PM) (Detached)
1 Socket in/var/run/screen/s-root.
[Email protected]:~# Screen-dms Myworker
[Email protected]:~# screen-ls
There is screens on:
2210.MyWorker (03/04/2018 12:38:55 PM)(Detached)
1883.PTS-0.XKFX (03/04/2018 12:06:15 PM) (Detached)
2 Sockets in/var/run/screen/s-root.
[Email protected]:~# screen-r 2227.MyWorker
(Screen-r 2227 or Screen-r myworker are available)
[Email protected]:/# screen-ls
There is screens on:
2227.MyWorker (03/04/2018 12:40:00 PM) (attached)
1883.PTS-0.XKFX (03/04/2018 12:06:15 PM) (Detached)
2 Sockets in/var/run/screen/s-root.
[Email protected]:/# cd/opt/antpool/cpuminer-2.5.0/
[Email protected]:/opt/antpool/cpuminer-2.5.0#./minerd-o stratum+tcp://stratum-ltc.antpool.com:8888-u xkfx.01
[2018-03-04 12:45:10] 1 miner threads started, using ' scrypt ' algorithm.
[2018-03-04 12:45:10] Starting stratum on stratum+tcp://stratum-ltc.antpool.com:8888
[2018-03-04 12:45:12] Thread 0:4104 hashes, 15.34 khash/s
[Detached from 2227.MyWorker]
(The action here is Ctrl + A + D)
[Email protected]:~# screen-ls
There is screens on:
2227.MyWorker (03/04/2018 12:40:00 PM)(Detached)
1883.PTS-0.XKFX (03/04/2018 12:06:15 PM) (Detached)
2 Sockets in/var/run/screen/s-root.
OK, now it's time to shut down and sleep on your nap.
Wake up to see if the program is still running:
[Email protected]:~# screen-ls
There is screens on:
2227.MyWorker (03/04/2018 12:39:59 PM) (Detached)
1883.PTS-0.XKFX (03/04/2018 12:06:14 PM) (Detached)
2 Sockets in/var/run/screen/s-root.
[Email protected]:~# screen-r 2227.MyWorker
[2018-03-04 13:26:38] Accepted:28/28 (100.00%), 15.55 khash/s (YAY!!!)
[2018-03-04 13:27:38] Thread 0:932832 hashes, 15.55 khash/s
[2018-03-04 13:27:39] Thread 0:9480 hashes, 15.58 khash/s
[2018-03-04 13:27:39] Accepted:29/29 (100.00%), 15.58 khash/s (YAY!!!)
[2018-03-04 13:28:14] Thread 0:539904 hashes, 15.55 khash/s
[2018-03-04 13:28:14] Accepted:30/30 (100.00%), 15.55 khash/s (YAY!!!)
3. Application
Solve the last remaining problem:
[Email protected]:~# Screen-dms mychatroomserver
[Email protected]:~# screen-r mychatroomserver
[Email protected]:~# Java-jar Main.jar
The server is listening on 10000 port ...
[Detached from 2586.myChatroomServer]
Disconnect the SSH test after the operation is complete:
PS: End a screen, cut into the screen, Ctrl + D
Linux Notes #05 # Keep programs running after disconnecting remote connections