Search code examples
.netlinuxubuntusystemdsystemctl

Error During creation of service for .net application on ubuntu 18.4. Executable path is not absolute:


I am trying to create a service for my .net run command.

cd /lib/systemd/system/YellowPages.service

[Unit]
Description = Yellow pages .NET service

[Service]
Type=forking
WorkingDirectory=/home
ExecStart=dotnet /home/yp_app/YellowPages.dll

[Install]
WantedBy=multi-user.target

I have my application on /home/yp_app.

when I run:systemd start YellowPages.service I get Excess arguments.

so I tried with: systemctl start YellowPages.service I get

   Failed to start YellowPages.service: Unit YellowPages.service is not loaded properly: Exec format error.
See system logs and 'systemctl status YellowPages.service' for details.

When I look into cat /var/log/syslog

I could see

systemd[1]: /lib/systemd/system/YellowPages.service:7: Executable path is not 
absolute: dotnet /home/yp_app/YellowPages.dll

I am new to Linux I am wondering where I am wrong. Could anyone help me with this?


Solution

  • According to the manual, ExecStart needs to be an absolute path to your executable. However you are simply using dotnet, simply change it to:

    ExecStart=/[path]/dotnet  /home/yp_app/YellowPages.dll
    

    For more info, you can refer to https://www.freedesktop.org/software/systemd/man/systemd.service.html