Archive

HowTo: cgminer as systemd service

Ok, I have been setting up my http://cubieboard.org/ up with https://fedoraproject.org/ to be able to control my http://www.butterflylabs.com/ hardware.

Obviously, I had to compile cgminer, which is straightforward.

So, I want the CubieTruck to start https://github.com/ckolivas/cgminer, automatically, as a http://freedesktop.org/wiki/Software/systemd/ process.

I need a service unit:

# /etc/systemd/system/cgminer.service
[Unit]
Description=Start mining bitcoin
After=syslog.target network.target nss-lookup.target

[Service]
Type=forking
ExecStart=/usr/local/bin/cgminer --syslog --real-quiet -o stratum+tcp://stratum.mining.eligius.st:3334 -u 1K7FEkbvBtMvtyT7S3RrPjuqWuJWfgUZBa -p somepassword -l 9

[Install]
WantedBy=multi-user.target

And there it is! Next, just activate it to start on boot and start it:

su -c 'systemctl enable cgminer.service'
sy -c 'systemctl start cgminer.service'

If you wanna check out the output of cgminer; which is a lot, btw, you need journalctl:

su -c 'journalctl -u cgminer -f'

I recommend setting some sane limits on your journalctl.conf file:

# /etc/systemd/journald.conf
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.
#
# See journald.conf(5) for details

[Journal]
#Storage=auto
Compress=yes
#Seal=yes
#SplitMode=login
#SyncIntervalSec=5m
#RateLimitInterval=30s
#RateLimitBurst=1000
SystemMaxUse=100M
#SystemKeepFree=
SystemMaxFileSize=20M
RuntimeMaxUse=100M
#RuntimeKeepFree=
RuntimeMaxFileSize=20M
#MaxRetentionSec=
#MaxFileSec=1month
#ForwardToSyslog=yes
#ForwardToKMsg=no
#ForwardToConsole=no
#TTYPath=/dev/console
#MaxLevelStore=debug
#MaxLevelSyslog=debug
#MaxLevelKMsg=notice
#MaxLevelConsole=info

Now, I am no guru or anything like that. I might've missed some stuff. Keep the feedback coming, dudesses and dudes!