mersenneforum.org

mersenneforum.org (https://www.mersenneforum.org/index.php)
-   PrimeNet (https://www.mersenneforum.org/forumdisplay.php?f=11)
-   -   Starting mprime at boot (https://www.mersenneforum.org/showthread.php?t=22886)

daxmick 2018-01-04 21:52

Starting mprime at boot
 
Us Linux folk have options on how our system boots. That said, most modern flavors of Linux have converted to something called "systemd". This boot "manager" starts daemons differently than us grey beards are used to. So, I thought I'd document what/how I've done to get my systemd machine (aka Ubuntu 17.10) to run mprime at bootup.

Note: Use these steps after you have ran [B]mprime -m[/B] to configure your system's profile.

First, change directory to the location where the boot scripts are stored:
[CODE]cd /etc/systemd/system[/CODE]Create a new file. I called mine mprime.service:
[CODE]sudo nano mprime.service[/CODE]Insert the following into that file:
[CODE][Unit]
Description=GIMPS mprime service
After=network.target

[Service]
Type=simple
User=daxm
WorkingDirectory=/home/daxm/mersenne/mprime
ExecStart=/home/daxm/mersenne/mprime/mprime -d
Restart=on-abort

[Install]
WantedBy=multi-user.target[/CODE]Change the "User", "WorkingDirectory" and "ExecStart" to lines to be what works for your setup and where you installed mprime.

Save that file by typing [B]control-x[/B] press [B]y[/B] and then press [B]ENTER[/B].

Change the file to be executable with this command:
[CODE]sudo chmod 755 mprime.service[/CODE]Now that the file exists and is executable we need to let the systemd process know to run it at bootup. Issue the following command to do so:
[CODE]sudo systemctl enable mprime.service[/CODE]Issue the following command to manually start this service.
[CODE]systemctl start mprime.service[/CODE]Verify it loaded correctly with this command:
[CODE]sudo systemctl status mprime.service[/CODE]Reboot your box. Then rerun the verification commands to see if your mprime service is running!

If you modify your mprime.service file. You'll need to issue the following command to reload systemd with the changes:
[CODE]sudo systemctl daemon-reload[/CODE]Happy GIMPS'ing!

daxmick 2018-01-04 23:20

I forgot to attribute my learning about how to build a Unit file. I used the following website:
[url]https://www.devdungeon.com/content/creating-systemd-service-files[/url]

Dubslow 2018-01-04 23:23

Surely the final command could be replaced with something like [c]systemctl reload mprime.service[/c]? So that systemctl doesn't reload *all* running services, rather just the one you want.

daxmick 2018-01-04 23:40

[QUOTE=Dubslow;476446]Surely the final command could be replaced with something like [c]systemctl reload mprime.service[/c]? So that systemctl doesn't reload *all* running services, rather just the one you want.[/QUOTE]

Good catch. I didn't see that. (I was caught up in formatting the post message.) Doh! However, reload isn't an option. It's restart. :-)

[CODE]sudo systemctl restart mprime.service[/CODE]

daxmick 2018-01-04 23:43

As an aside, you can use the following command to look at the "log" for this service:
[CODE]journalctl -u mprime.service[/CODE]

Dubslow 2018-01-05 01:47

[QUOTE=daxmick;476448]Doh! However, reload isn't an option. It's restart. :-)

[CODE]sudo systemctl restart mprime.service[/CODE][/QUOTE]

Ah yes, I forgot that mprime isn't such sophisticated software as, say, an HTTP server or ssh daemon :smile:

TheJudger 2018-01-05 19:31

There is no need to set the executable bit on mprime.service.

Oliver

daxmick 2018-01-05 19:33

[QUOTE=TheJudger;476574]There is no need to set the executable bit on mprime.service.

Oliver[/QUOTE]

To be honest, I wasn't sure. It makes sense that you wouldn't but I did what I learned. :-)

heliosh 2018-01-05 19:54

Thanks for sharing. This could be in the mprime package.

Nick 2018-01-05 21:14

[QUOTE=heliosh;476589]Thanks for sharing. This could be in the mprime package.[/QUOTE]
Don't forget the Slackware users who still have init!

daxmick 2018-01-05 21:16

[QUOTE=Nick;476603]Don't forget the Slackware users who still have init![/QUOTE]

Wow. Slackware. Now there is an OS that I haven't run in... 15 years. :smile:


All times are UTC. The time now is 05:53.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.