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


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.

  • how do I run it under specific user?
    – Index
    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. Oct 30, 2017 at 3:52
  • Under which user will it run by default?
    – Index
    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. Oct 30, 2017 at 10:15

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


        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
  • How do you make it a startup background service? 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.