Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.6k views
in Technique[技术] by (71.8m points)

ubuntu - Unit service is not loaded properly: Exec format error. on ubuntu18.04 creating .net service

I am trying to create a service to run by .net application on ubuntu 18.04.

cd /lib/systemd/system/YellowPages.service

[Unit]
Description = Yellow pages .NET service

[Service]
Type=forking
WorkingDirectory=/home/yp_app
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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

There are a couple of issues with your daemon:

[Unit]
Description = Yellow pages .NET service

Remove spaces around equal sign:

[Unit]
Description=Yellow pages .NET service

ExecStart needs an absolute path (hence the error):

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

Your dotnet executable might be located elsewhere, although you can find out its absolute path by doing:

$ which dotnet

Whatever is returned would be the absolute path to use.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...