1

I'm developping a dotnet core service to run in rpi4, and when i execute the service with "dotnet run rpiservice.dll" the code executes normally. So, i created a .service file and insert in /etc/systemd/system folder. Here's my file:

[Unit]
Description=ANA Service

[Service]
ExecStart=/opt/dotnet/dotnet RpiGateway.dll
WorkingDirectory=/home/stationpi/RpiGateway
Restart=always
RestartSec=10
User=stationpi


[Install]
WantedBy=multi-user.target

But when i reboot rpi the service doesn't started. When i check the status with "systemctl status rpi.service" returns me "inactive(dead)".

I try many things, and when i change the WantedBy to "default.target" the service started normally on boot.

Anyone knows why multi-user.target doesn't work? Many tutorials that teach how to create a service in rpi use multi-user.target.

Thanks a lot!

1 Answer 1

2

Anyone knows why multi-user.target doesn't work? Many tutorials that teach how to create a service in rpi use multi-user.target.

Likely because multi-user.target is not the default target; if you installed from the "full" (ie., not "lite") version of Rpi OS, the default will be graphical.target.

You can check this with:

> systemctl get-default

If you want to change it:

> sudo systemctl set-default multi-user

However, unless you have some particular reason to do that, you might as well leave it the way it is. It's also usually best to use WantedBy=default.target as that will match the active target regardless of whether it is graphical or multi-user or whatever.

1
  • thanks for the explanation! Commented Mar 24 at 17:43

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.