I am running xmrig-5.8.1 on Ubuntu 18.04 by executing this cmd ./xmrig --donate-level 1 -o pool.supportxmr.com:xyz -u MY-XMR-ADDRES -p Rig1 -k --tls. Now I want it to start automatically in background whenever I start my system. I found some way like adding a script file inside init or init.d folder but I don't know how to add the script file inside these folder and what to add inside these script file?


There are many ways to do this. One simple way is via cron:

In a shell execute crontab -e then add and edit the line:

@reboot /path/to/xmrig -B [--syslog | --log-file=/some/file.log] [your other options] 

Save and exit.

The -B option runs it in the background and you add either the --syslog or --log-file option so you can get at its output.

Many other Ubuntu examples of running things at startup here: https://askubuntu.com/questions/814/how-to-run-scripts-on-start-up

  • my xmrig file is in home/user/xmrig5.8/xmrig So it should be done like this @reboot home/user/xmrig5.8/xmrig -B [--log-file=/some/file.log] so then what is the use of this cmd ./xmrig --donate-level 1 -o pool.supportxmr.com:xyz -u MY-XMR-ADDRES -p Rig1 -k --tls @jtgrassie
    – doremon
    Apr 5 '20 at 3:01
  • @reboot /home/user/xmrig5.8/xmrig -B --log-file=/some/file.log --donate-level 1 -o pool.supportxmr.com:xyz -u MY-XMR-ADDRES -p Rig1 -k --tls
    – jtgrassie
    Apr 5 '20 at 3:16
  • Shouldn't it be something like su - user -c bla bla.. ? Apr 5 '20 at 3:29
  • Depends which users crontab was edited and which user it is wanted to be run as. Also, you don't need to use su in crontabs as you can just place the user name between the time section and command. e.g. @reboot bob /home/bob/xmrig ....
    – jtgrassie
    Apr 5 '20 at 4:13
  • home/user/xmrig5.8/xmrig this is my xmrig file path find you own and add this in startup application this worked for me 100% it will work for you also.
    – doremon
    Jan 13 '21 at 3:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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