Bitcoin Forum

Bitcoin => Mining support => Topic started by: bitcoinminer42 on April 16, 2013, 09:51:22 PM



Title: ubuntu: cgminer as service (/etc/init.d) or as cron
Post by: bitcoinminer42 on April 16, 2013, 09:51:22 PM
hi there!

i plan to automate my mining rigs.
doeas anyone installed cgminer as a linux sercice?
i have several problems with overclocking of my 7950 cards

other idea is to use cron to automatically start cgminer at system start.

thanks, bcm42


Title: Re: ubuntu: cgminer as service (/etc/init.d) or as cron
Post by: GoldSeal on April 16, 2013, 11:14:09 PM
do not use cron for anything like that. that's not going to work cleanly.

This is not too difficult. Start cgminer from an init script with --syslog or --sharelog options. The init script should be set to start for run levels 2345. (man update-rc.d on ubuntu for example) You should put any environment variables required to start cgminer into /etc/profile and wrap your cgminer command with:

bash -lc 'cgminer --blah --blah ---blah'

This command ensures that the program is run with a user environment and no TTY.

Another method to set environmental variables is to front load your command with the environment variables you wish to set. I've run into this when using cgminer for litecoin.

Other than that I would suggest using monit to monitor the process  and restart it when it fails. M/Monit is extremely useful as well if you want a web GUI to manage a monit agent.

If you need help with this, I'm planning to assemble a ubuntu based mining rig with 6 cards next week. I can post my init script, monit configs, and other setup details from that install when I do it.


Title: Re: ubuntu: cgminer as service (/etc/init.d) or as cron
Post by: bitcoinminer42 on April 17, 2013, 07:36:36 AM
that would be great ;-) thx


Title: Re: ubuntu: cgminer as service (/etc/init.d) or as cron
Post by: slakeco on April 18, 2013, 12:59:49 AM
I'm planning to assemble a ubuntu based mining rig with 6 cards next week. I can post my init script, monit configs, and other setup details from that install when I do it.

Yes, please +1


Title: Re: ubuntu: cgminer as service (/etc/init.d) or as cron
Post by: GoldSeal on April 19, 2013, 07:04:48 PM
The post is coming by today to drop off my PSU and riser cables. So I should have something for you guys this weekend.


Title: Re: ubuntu: cgminer as service (/etc/init.d) or as cron
Post by: GoldSeal on April 22, 2013, 12:46:37 AM
I had a miner setback this weekend with an incompatible motherboard. I picked up a new MB, cpu, and mem yesterday. I'm still working on this and should have something posted soon.


Title: Re: ubuntu: cgminer as service (/etc/init.d) or as cron
Post by: glub0x on April 22, 2013, 07:55:48 AM
i spend yesterday evening trying to do this ...
i actually manage to launch a basic .sh script at boot ( mkdir /test ) using the gnome-session startup program

but if instead i put cgminer blahblah it just doesn't work.
I also try init.d folder and rc.local with no more result.


Would be nice if ubuntu just start, then the terminal pop-up and cgminer starts


Title: Re: ubuntu: cgminer as service (/etc/init.d) or as cron
Post by: -ck on April 22, 2013, 10:55:14 AM
Launch cgminer via screen


Title: Re: ubuntu: cgminer as service (/etc/init.d) or as cron
Post by: glub0x on April 22, 2013, 05:58:08 PM
Launch cgminer via screen
sounds like THE solution! i'll give it a try and keep update.


Title: Re: ubuntu: cgminer as service (/etc/init.d) or as cron
Post by: crazyates on April 22, 2013, 06:42:27 PM
Launch cgminer via screen
sounds like THE solution! i'll give it a try and keep update.
Someone previously suggested byobu, and that's what I use.


Title: Re: ubuntu: cgminer as service (/etc/init.d) or as cron
Post by: glub0x on April 22, 2013, 07:44:10 PM
Launch cgminer via screen
sounds like THE solution! i'll give it a try and keep update.
Someone previously suggested byobu, and that's what I use.
I ll try that.

I just tried screen and it doesn't do what i want.
If i do  in the terminal
screen sh adress/to/my/script.sh
It does launch the script just like if i type sh adress/to/my/script.sh

Now when i restart the computer it seems to do nothing (not poping a terminal windows with cg miner)...


[EDIT] I finally get what i wanted.
I used this startup.sh script that i put on the desktop
Code:
#!/bin/sh
gnome-terminal -x sh /home/XXX/cgminer/mycgminercommand.sh

then i used the Startup Application utility of Ubuntu and linked to my  startup.sh script


Every time my computer reboot a terminal popup with cgminer inside.


Title: Re: ubuntu: cgminer as service (/etc/init.d) or as cron
Post by: Marrs on April 22, 2013, 07:46:28 PM
Launch cgminer via screen
sounds like THE solution! i'll give it a try and keep update.
Someone previously suggested byobu, and that's what I use.
I ll try that.

I just tried screen and it doesn't do what i want.
If i do  in the terminal
screen sh adress/to/my/script.sh
It does launch the script just like if i type sh adress/to/my/script.sh

Now when i restart the computer it seems to do nothing (not poping a terminal windows with cg miner)...



Like this:

Code:
/usr/bin/screen -A -d -m -S cgminer /path/to/cgminer -c /otherpath/to/cgminer.conf --whatever-other-parameters

Then you can bring it to the foreground later using:

Code:
screen -d -r

Then put it back into the background (aka detach) by typing CNTL-a d



Title: Re: ubuntu: cgminer as service (/etc/init.d) or as cron
Post by: GoldSeal on April 28, 2013, 01:09:59 AM
Sorry for the late update. I ended up using a wrapper script which calls mine.sh that sets the environement and launches cgminer.

In xcfe4 I added the wrapper script to the list of items run at startup and configured auto-login on boot. This works fine as long as mine.sh exports display to :0 and you add a 15 sec sleep to the front of the wrapper script. MY cgminer is configured to output to syslog and I load ths data into Splunk. Splunk provides me with email based alerting  and I can make a pretty nice graphical dashboard to monitor the box etc.

Later this week I'll see about getting an init script together to launch the wrapper script with the proper uid, etc. Once that works, I'll configure monitr to restart the service automatically. I'll need a bit more time to do this. I've been busy this week. =)