NajmAjmal / xmrig-install-raspberrypi

Install Commands for XMRig on Raspberry Pi - How to Install XMRig on Raspberry pi
Apache License 2.0
15 stars 3 forks source link

Miner in the background #4

Closed Coll147 closed 1 year ago

Coll147 commented 1 year ago

How could I leave the miner in the background so that it continues mining after closing the terminal?

NajmAjmal-old commented 1 year ago

Hi @Coll147,

Are you using a GUI or CLI OS whilst running this program?

Coll147 commented 1 year ago

I'm using rpios lite (cli), although I was able to do it in the end with a service. Here I share the file I made:

[Unit]
Description= Monero Miner
After=network-online.target
Wants=network-online.target

[Service]
ExecStart=/home/aaron/xmrig/build/xmrig -o gulf.moneroocean.stream:10128 
-u 491pX3z7pdeixRPPJWBK7KZ6hPysWEw3nj36A7YBTtAQ4Es5bWoVvNSU7KNhcuxB6x6ZT4Wg3hcHPMax4KwRnG2Q3uQb3FX-p pi4
WorkingDirectory=/home/aaron/xmrig/build
Restart=always
RestartSec=20

[Install]
WantedBy=multi-user.target

I hope it can help others who have a question similar to the one I had.

NajmAjmal-old commented 1 year ago

Hi @Coll147,

To run xmrig in the background on your Raspberry Pi, you can use the & symbol at the end of the command, or you can use the nohup command. Here are both methods:

Method 1: Using the & symbol

  1. Open a terminal window on your Raspberry Pi.

  2. Navigate to the directory where xmrig is located. Based on your provided script, it appears to be in the /home/aaron/xmrig/build/ directory.

  3. Run xmrig in the background using the & symbol and specify your mining parameters as needed:

    ./xmrig -o gulf.moneroocean.stream:80 -u 4657q4dnsjLWtzeW4XN3wG9swFumWAZB9i1pegTLMxVAQy5E5AE8uif42kkHWcWc9vDcLUmzeCf3pV7mmrJQQqqe84dtASi -p Raspberry-Pi &

    This command will start xmrig in the background, and you will get your terminal prompt back.

Method 2: Using nohup

  1. Open a terminal window on your Raspberry Pi.

  2. Navigate to the directory where xmrig is located. Based on your provided script, it appears to be in the /home/aaron/xmrig/build/ directory.

  3. Run xmrig in the background using the nohup command:

    nohup ./xmrig -o gulf.moneroocean.stream:80 -u 4657q4dnsjLWtzeW4XN3wG9swFumWAZB9i1pegTLMxVAQy5E5AE8uif42kkHWcWc9vDcLUmzeCf3pV7mmrJQQqqe84dtASi -p Raspberry-Pi &

    This command will start xmrig in the background and detach it from the terminal. It will also redirect the output to a file named nohup.out in the same directory.

After using either method, xmrig will continue running in the background, allowing you to use the terminal for other tasks. You can check the mining progress and view logs as needed.

If these methods do not work, re-open this issue.

Thanks, Najm