running executable on boot

General support questions
Post Reply
supertight
Posts: 171
Joined: 2017/02/07 21:47:51

running executable on boot

Post by supertight » 2017/12/11 06:08:20

I want xmr-stak-cpu to start and run whenever the machine is booted Or to run in the background.

I can start it with:

Code: Select all

cd /root/xmr-stak-cpu/bin
./xmr-stak-cpu
When I try and shift it the the background and disown -h with:

Code: Select all

CTL+Z
bg %* 
stops the job all together. I can't get it to run in the background so I can disown and close the putty window.

I'll take either solution. Running on boot or shifting it into the background.
Can someone point me into the correct direction? thank you.

User avatar
jlehtone
Posts: 4523
Joined: 2007/12/11 08:17:33
Location: Finland

Re: running executable on boot

Post by jlehtone » 2017/12/11 08:39:38

Create a systemd unit for your service.

supertight
Posts: 171
Joined: 2017/02/07 21:47:51

Re: running executable on boot

Post by supertight » 2017/12/12 00:44:33

jlehtone wrote:Create a systemd unit for your service.
Doing this now.

supertight
Posts: 171
Joined: 2017/02/07 21:47:51

Re: running executable on boot

Post by supertight » 2017/12/12 21:59:27

jlehtone wrote:Create a systemd unit for your service.
I added a user, xmr
I setup /etc/systemd/systemxmr.service with the following code:

Code: Select all

[root@miner01 system]# cat xmr.service
[Unit]
Description: XMR-STAK-CPU MINING
After=network.target

[Service]
Type=simple
User=xmr
ExecStart=/root/xmr-stak-cpu/bin/xmr-stak-cpu -s
Restart=on-abort


[Install]
WantedBy=multi-user.target
using systemctl status xmr.service I get the following error.

Code: Select all

[root@miner01 system]#  -l
-bash: -l: command not found
[code]
[root@miner01 ~]# systemctl status xmr.service -l
● xmr.service
   Loaded: error (Reason: Bad message)
   Active: inactive (dead)

Dec 12 15:00:13 miner01 systemd[1]: [/etc/systemd/system/xmr.service:2] Missing '='.
Dec 12 15:00:36 miner01 systemd[1]: [/etc/systemd/system/xmr.service:2] Missing '='.
I'm not sure what I'm doing wrong. Can someone get me moving in the correct direction?

User avatar
jlehtone
Posts: 4523
Joined: 2007/12/11 08:17:33
Location: Finland

Re: running executable on boot

Post by jlehtone » 2017/12/12 23:36:28

supertight wrote:I'm not sure what I'm doing wrong.

Code: Select all

[/etc/systemd/system/xmr.service:2] Missing '='.
Error message: Line 2 does not have an equal sign.
supertight wrote:

Code: Select all

# cat xmr.service
[Unit]
Description: XMR-STAK-CPU MINING
Yes,

Code: Select all

Description: XMR-STAK-CPU MINING
does not have '='.

supertight
Posts: 171
Joined: 2017/02/07 21:47:51

Re: running executable on boot

Post by supertight » 2017/12/13 01:34:27

jlehtone wrote:
supertight wrote:I'm not sure what I'm doing wrong.

Code: Select all

[/etc/systemd/system/xmr.service:2] Missing '='.
Error message: Line 2 does not have an equal sign.
supertight wrote:

Code: Select all

# cat xmr.service
[Unit]
Description: XMR-STAK-CPU MINING
Yes,

Code: Select all

Description: XMR-STAK-CPU MINING
does not have '='.
ugh, I should have been able to deduce that. I'll put on my yellow cone hat and sit in the corner.
Thank you for the help.

supertight
Posts: 171
Joined: 2017/02/07 21:47:51

Re: running executable on boot

Post by supertight » 2017/12/13 03:08:17

jlehtone wrote:
supertight wrote:I'm not sure what I'm doing wrong.

Code: Select all

[/etc/systemd/system/xmr.service:2] Missing '='.
Error message: Line 2 does not have an equal sign.
supertight wrote:

Code: Select all

# cat xmr.service
[Unit]
Description: XMR-STAK-CPU MINING
Yes,

Code: Select all

Description: XMR-STAK-CPU MINING
does not have '='.
Now I'm getting.

Code: Select all

[root@miner01 system]# systemctl status xmr.service -l
● xmr.service - XMR-STAK-CPU MINING
   Loaded: loaded (/etc/systemd/system/xmr.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Tue 2017-12-12 20:05:13 MST; 1min 17s ago
  Process: 2926 ExecStart=/root/xmr-stak-cpu/bin/xmr-stak-cpu -s (code=exited, status=203/EXEC)
 Main PID: 2926 (code=exited, status=203/EXEC)

Dec 12 20:05:13 miner01 systemd[1]: Started XMR-STAK-CPU MINING.
Dec 12 20:05:13 miner01 systemd[1]: Starting XMR-STAK-CPU MINING...
Dec 12 20:05:13 miner01 systemd[2926]: Failed at step EXEC spawning /root/xmr-stak-cpu/bin/xmr-stak-cpu: Permission denied
Dec 12 20:05:13 miner01 systemd[1]: xmr.service: main process exited, code=exited, status=203/EXEC
Dec 12 20:05:13 miner01 systemd[1]: Unit xmr.service entered failed state.
Dec 12 20:05:13 miner01 systemd[1]: xmr.service failed.
Edit: Update
I changed permission/ownership for the folders and config files. It sill wont open the config file.

now I'm getting:

Code: Select all

● xmr.service - XMR-STAK-CPU MINING
   Loaded: loaded (/etc/systemd/system/xmr.service; disabled; vendor preset: disabled)
   Active: inactive (dead)

Dec 12 20:59:56 miner01 systemd[1]: Started XMR-STAK-CPU MINING.
Dec 12 20:59:56 miner01 systemd[1]: Starting XMR-STAK-CPU MINING...
Dec 12 20:59:56 miner01 xmr-stak-cpu[1203]: [2017-12-12 20:59:56] : Failed to open config file config.txt.
Dec 12 21:32:33 miner01 systemd[1]: Started XMR-STAK-CPU MINING.
Dec 12 21:32:33 miner01 systemd[1]: Starting XMR-STAK-CPU MINING...
Dec 12 21:32:33 miner01 xmr-stak-cpu[1425]: [2017-12-12 21:32:33] : Failed to open config file config.txt.

tunk
Posts: 1205
Joined: 2017/02/22 15:08:17

Re: running executable on boot

Post by tunk » 2017/12/13 11:00:22

Could be caused by selinux, you may find some info in /var/log/messages.

supertight
Posts: 171
Joined: 2017/02/07 21:47:51

Re: running executable on boot

Post by supertight » 2017/12/13 17:48:26

tunk wrote:Could be caused by selinux, you may find some info in /var/log/messages.
SELinux is disabled. Checking log.

Edit: update
/var/log/messages showing the same info as above.

Code: Select all

Dec 12 21:32:33 miner01 xmr-stak-cpu: [2017-12-12 21:32:33] : Failed to open config file config.txt.

Post Reply