2

I'm running Ubuntu 14.04. And I need to run xmr-stak-cpu as a service. I tried to search for a possible solution, but found only for systemctl, which is on Ubuntu 16. Is there a way/script to configure and run xmr-stak-cpu on Ubuntu 14.04 as a service?

Index
  • 111
  • 1
  • 11

2 Answers2

4

Have you tried upstart? See http://upstart.ubuntu.com/cookbook/

Also see: https://askubuntu.com/questions/351879/how-to-create-a-service-on-ubuntu-upstart/448536#448536

Upstart Example: /etc/init/xmrstakcpu.conf

# xmrstakcpu.conf
start on net-device-up IFACE=eth0
exec /usr/local/bin/xmr-stak-cpu/xmr-stak-cpu

This would run /usr/local/bin/xmr-stak-cpu/xmr-stak-cpu after the Ethernet0d device was initialized.

If you just want to run xmr-stak-cpu in background - for instance after SSH - you can use

nohup ./xmr-stak-cpu &

This will run xmr-stak-cpu and keep it active in background and log all output to a file nohup.out, while you can logout / exit SSH.

Mario Werner
  • 186
  • 2
2

To create new upstart config

sudo nano /etc/init/xmrstakcpu.conf

Example of upstart configuration:

description "xmr-stak-cpu"
start on filesystem and net-device-up IFACE!=lo

script

        echo $$ > /var/run/xmr.pid
        exec su -s /bin/bash -c "nice -n19 /path/xmr-stak-cpu/bin/xmr-stak-cpu /path/xmr-stak-cpu/bin/config.txt" user_under_which_xmr_will_start

end script

pre-start script
    echo "[`date`] Starting" >> /var/log/xmr.log
end script

pre-stop script
    rm /var/run/xrm.pid
    echo "[`date`] Stopping" >> /var/log/xmr.log
end script

Service usage:

sudo service xmrstakcpu start
sudo service xmrstakcpu stop
Index
  • 111
  • 1
  • 11