Post
Topic
Board Mining software (miners)
Re: Is there a tutorial for using screen to auto start cgminer?
by
flatronw
on 24/08/2012, 12:01:40 UTC
For BTC Keeper

At the outset I dont know shit about Linux but the following works for me. It basically came from this post Topic but it took me a while to get it sorted out. Everybody who posts seems to assume that every one else reading has the same skill levels as they do and they leave little "Important" bits out. I will try not to do that so if it is all a bit basic I aplogise!

Use these two scripts, the first named "stminer.sh" the second named "cgmlaunch.sh" As you can see both these are .sh files. You need to create those .sh files with the posted text inside. And make them executable
----------------------------------------------
#!/bin/sh
screen -dmS 051 ./cgmlaunch.sh
------------------------------------------------
and
------------------------------------------------
#!/bin/sh
sleep 60
export DISPLAY=:0
xhost +
now="`date +%Y%m%d%H%M%S`"
cd /home/miner/cgminer-2.3.2
./cgminer   2>log.$now$$.10151.txt
------------------------------------------------
If you look at the second script you will see the line "cd /home/miner/cgminer-2.3.2"
That shows you the directory where both scripts need to be put ie your equivalent of /home/miner. Where miner is your "named" directory. You need to give both scripts execution rights by chmod or the easy way just use the properties box/permissions and check "allow execution". You need to change "cgminer-2.3.2" to whatever you have called your installed version of cgminer and it must be in that "/miner" directory

The first script starts Screen, names it .051 and then it starts the second script, which waits 60 seconds then starts cgminer and creates a log file called 10151.txt in your cgminer directory. If you dont want the log file delete "2>log.$now$$.10151.txt" from the last line of the second script
(Use the cgminer.config file in  /home/miner/.cgminer for your GPU parameters.)

To get the first script to run at start-up you need to use the Startup Applications in Ubuntu, go to System/Preferences/Startup Applications click Add, put in a description eg "Start CGMiner" then browse to find the first script, in my case called "stminer.sh" select it, make sure the box is ticked and exit.

If all has gone according to plan and I have not left any important little bits out. When you reboot you machine will eventually start and run your cgminer. BUT it will start in "Headless Mode"
You can ssh into the machine and use Screen to view the CGMiner data.
I am guessing but I think, if you dont want Screen to run then maybe if you were to select the second script ie "cgmlaunch.sh" instead of the first in the Startup Application then maybe it will start cgminer directly.

Hope this ease's the pain.

I am sure there are more elegant and sophisticated ways of doing the above. However this has worked flawlessly for me on two machines for more than 6 months. Both on USB boot and HDD boot and its Newbie do-able!


Edit:- corrected last line of the second script to read as per the correction in Kano's post below.

This is cut and paste of the last line of the second script from one of my running miners:-  ./cgminer 2>run.$now.$$.log10151.txt