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?

2 Answers 2

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.

4
  • how do I run it under specific user?
    – Index
    Commented Oct 29, 2017 at 18:35
  • You can run programs under a different user using the su command. But I doubt this works for services. Commented Oct 30, 2017 at 3:52
  • Under which user will it run by default?
    – Index
    Commented Oct 30, 2017 at 8:41
  • Not sure. You can try it and after it runs you can use ps to see what user it is running on. Commented Oct 30, 2017 at 10:15
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
1
  • How do you make it a startup background service? Commented Nov 21, 2017 at 6:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.