How To Install / Use Linux Screen

in #mining7 years ago (edited)

Hello Again, I have decided to make this How To because I was searching a lot until I found this command/function. Without this utility I was forced to leave open the ssh session because if I was closing the session my miner wasn't running anymore.
I use my Raspberry Pi to mine cryptocurrency, if you want to know how check this link https://steemit.com/bitcoin/@dury10/miner-how-to-start-mining-verium-on-raspberry-pi-3-step-by-step-for-noobs

On my Raspberry Pi3 I use Pi64 OS, if you want to know more about this and how to install it, check this link https://steemit.com/raspberry/@dury10/how-to-install-64-bit-os-on-a-raspberry-pi-3-step-by-step-for-newbies

What its Linux Screen? Linux Screen allows you to:

Use multiple shell windows from a single SSH session.
Keep a shell active even through network disruptions.
Disconnect and re-connect to a shell sessions from multiple locations.
Run a long running process without maintaining an active shell session.

If you want to know more about ssh and how to install it on linux check this link https://steemit.com/raspberry/@dury10/how-to-install-use-ssh-on-a-raspberry-pi-3-step-by-step-for-noobs

So let's get started:

  1. Start a SSH session log in to your Pi

  2. Let's install screen. I use pi64 os and screen it is not native so we need to install it.
    To install screen you just need to type this command :
    sudo apt-get install screen

  3. How to use Screen
    Les say you want to open in background your miner or whatever you want.
    First you need to type screen and pres enter, it will show you a screen with the names of the developers and the history of screen. You need to press enter and it will start like a new command line. Now you are in the same place (directory) you was when you executed the screen command.
    To start the mine we need to go to the miner folder, in our case "veriumMiner" so we need to type this command :
    cd veriumMiner/
    And now to start the miner type the specify command
    ./cpuminer -n 1048576 -o stratum+tcp://eu.vrm.mining-pool.ovh:3032 -u Weblogin.WorkerName -p WorkerPassword
    Now because you used screen if you close your session the miner will still work in background

  4. To see if you have any session open type this command
    screen -ls
    it will show you something like this

pi@raspberrypi:~$ screen -ls
There is a screen on:
       ` 987.pts-0.raspberrypi   (12/22/17 21:09:52)     (Detached)
1 Socket in /run/screen/S-pi.
pi@raspberrypi:~$

This means you have a screen process ruining in background

  1. To reattach to a opened session you have to type this command
    screen -r [session #of the process or the name of the process] in our case
    screen -r 987 or screen -r pts

  2. To detach from a screen session you need to use the CTRL+A+D
    You can also detach by closing the putty window and the process it will remain open

  3. To close / kill a screen process you need to type this command
    screen -X -S [session # you want to kill] kill
    in our case it will be
    screen -X -S 987 kill
    "kill" will only kill one screen window. To "kill" the complete session, use quit.
    screen -X -S [session # you want to kill] quit
    To close a screen session where all tasks are finished you can type
    exit

  4. Now let's create another screen session by typing.
    Ctrl +a+c
    A new, blank screen session opens

  5. Changing sessions, now you can browse your two screen sessions by running
    Ctrl+a+n or Ctrl a p

For more info you can type screen -help and it will show you all the Options that you have for screen function.
For even more detailed info you can run this command man screen

If you found this How to useful give it a Vote if you don't leave a comment why and do not forget to follow me for more how to's!
Feel free to use and improve this little tutorial

Sort:  

Congratulations @dury10! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

Award for the number of upvotes
Award for the number of upvotes received

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

By upvoting this notification, you can help all Steemit users. Learn how here!

Updated

Coin Marketplace

STEEM 0.22
TRX 0.26
JST 0.040
BTC 98083.48
ETH 3476.77
USDT 1.00
SBD 3.24