TUTORIAL | Auto-update and Auto-start scripts for mining rigs running on Linux
mining·@lifipp·
0.000 HBDTUTORIAL | Auto-update and Auto-start scripts for mining rigs running on Linux
<h3>So you have configured your Linux mining rig and it works flawlessly, but you do not want to check on it every day or maybe you are going on vacation and you have to leave your lovely mining rig at home for two weeks... alone... :O How to make sure that everything is going to work even without your support? It's unbelievably easy and straight forward - you just gotta write two simple scritps called <code>auto_start.sh </code> and <code>auto_update.sh</code></h3>  <h2>Step 0:</h2> First things first, before you start doing ANYTHING with your Linux system - always run: **<code>sudo apt-get update && sudo apt-get upgrade -y</code>** It's essential to keep your machine up to date before installing/configuring any new stuff. <h2> Step 1:</h2> Install tmux (that's a special thing for running multiple terminal windows/sessions and to be able to send keys keys in particular terminal window - it's gonna come in handy for our scripts): **<code>sudo apt-get install tmux</code>** <h2>Step 2:</h2> Now things are gonna get a lil bit more complicated - you are going to write those two scripts... :O Let's start with our **<code>auto_start.sh</code>** script first - open terminal, make sure, that you are in your **<code>home</code>** folder (looks like this in terminal: ~) and type: **<code>sudo nano auto_start.sh</code>**  Next an empty window of a terminal text editor should pop up. In that window type the following script: <b>`#!/bin/bash`</b> <b>`tmux new-session -d -n MINER`</b> <b>`tmux send-keys -t MINER "cd /your/path/to/miner/folder" C-m`</b> <b>`tmux send-keys -t MINER "sudo ./name_of_your_miner.sh" C-m`</b> <b>`tmux send-keys -t MINER "your_password" C-m`</b> <h6>*Where "your/path/to/miner/folder" represents the path to your miner folder, "your_password" your system password and "name_of_your_miner.sh" the name of the your miner's running script (obviously...). If you have other miner than EWBF"s CUDA or you are mining on AMD cards the starting script might have a different name so double check that! And btw. - you can name your session as you want - I named mine: MINER</h6> It should look like this:  When you're done press **<code>ctrl + O</code>** then **<code>enter</code>** and then **<code>ctrl + X</code>** to save and exit the text editor. The second script is **<code>auto_update.sh</code>** - in you terminal type: **<code>sudo nano auto_update.sh</code>**  You will be welcomed by the same terminal text editor as the last time. This time type this script: <b>`#!/bin/bash`</b> <b>`tmux new-session -t updater`</b> <b>`tmux send-keys -t updater "sudo apt autoremove --purge -y" C-m`</b> <b>`tmux send-keys -t updater "your_password" C-m`</b> <b>`tmux send-keys -t updater "sudo apt-get update && sudo apt-get upgrade -y" C-m`</b> <b>`tmux send-keys -t updater "tmux kill-window" C-m`</b> <h6>*Again - where "your_password" should be YOUR password :D and the session does not have to be called "updater" it can be called "nexus of the wisdom" if you would like to.</h6> It should like this:  Again: **<code>ctrl + O</code>**, **<code>enter</code>** and **<code>ctrl + X</code>** to save and exit the text editor. If you open your <b>`home`</b> folder you should find there your two scritps:  <h2> Step 3:</h2> In order to run and test them type in your terminal: <b>`sudo chmod +x auto_start.sh && sudo chmod +x auto_update.sh`</b> then: <b>`./auto_start.sh`</b> to run your. Nothing should happen - in order to see the mining process, you have to open the special tmux window that we've created in our script. Type: <b>`tmux attach`</b> (either in the same terminal or in new terminal window). If you have followed all the steps and typed everything right, you should see a terminal window pop up with your miner running:   To terminate the mininig process in your system open a separate terminal window and type: <b>`tmux kill-window -t MINER`</b>  this gives tmux a command to terminate the particular tmux window called "MINER" (or whatever your one is gonna be called like):  <h2>Step 4:</h2> To make these scripts run automatically on system boot, you gotta put them into the <b>`crontab`</b>. To do that type <b>`crontabe -e`</b> in your terminal window. You will be welcomed by a window full of text describing what crontab does and how to use it. Scroll to the bottom and there type: <b>`@reboot /path/to/your/auto_start_script`</b> <b>`@reboot /path/to/your/auto_update_script`</b> <h5> *I really do not have to explain what does that code after "@reboot" do, do I? :)</h5>  Then traditionally hit **<code>ctrl + O</code>**, **<code>enter</code>** and **<code>ctrl + X</code>** to save and exit the text editor. If there are no errors in your crontab command you should see the terminal writing that the new crontab is being installed:  And that's it - you are done! I strongly recommend you to turn off your password on log in and also turn off sleep mode in settings menu so that the system does not encounter any problems to run automatically by itself. To test the whole thing out reboot your system. Then open your terminal window and type: <b>`tmux attach`</b> if you see the miner running you've done everything right and now can care much less about your miner, because from now on it's fully automated! :) Please let me know in the comments below if everything went well, if you have any questions do not hesitate to ask - I would love to answer them. Upvote, resteem and follow me for more tutorials! Also check out my other tutorial on how to set up and configure mining rig running on Linux: https://steemit.com/cryptocurrency/@lifipp/tutorial-or-how-to-set-up-and-configure-your-mining-rig-on-linux-nvidia-cards --- <a><i><b>-lifipp a.k.a Hash Courier post #009</b></i></a>
👍 lifipp, attailah, curie, warofcraft, velourex, hendrikdegrote, jraysteem, ace108, mr-anderson, mae09, ew-and-patterns, jmehta, ribalinux, alexsandrbrat, kdogdiggles13, eth03, bilal7, amarie, pvelazquez4, joshdurston, aarkay, henro450, earfonia, andyonline, me-do, soon8013, woojoo, rudel, mhon, admiralmutiny, romz410,