Linux Notes #05 # Keep programs running after disconnecting remote connections

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.