单元服务未正确加载:Exec格式错误。关于ubuntu18.04创建.net服务

单元服务未正确加载:Exec格式错误。关于ubuntu18.04创建.net服务,ubuntu,service,ubuntu-18.04,systemd,systemctl,Ubuntu,Service,Ubuntu 18.04,Systemd,Systemctl,我正在尝试创建一个服务,由ubuntu 18.04上的.net应用程序运行 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=mul

我正在尝试创建一个服务,由ubuntu 18.04上的.net应用程序运行

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
~
我在/home/yp_应用程序上有我的应用程序

运行时:systemd启动YellowPages.service 我明白了 过度争论

所以我尝试了:systemctl start YellowPages.service 我明白了

当我查看cat/var/log/syslog时

我能看见

systemd[1]: /lib/systemd/system/YellowPages.service:7: Executable path is not 
absolute: dotnet /home/yp_app/YellowPages.dll
我是Linux新手,我想知道我错在哪里了。
有人能帮我解决这个问题吗?

您的守护进程有几个问题:

[Unit]
Description = Yellow pages .NET service
删除等号周围的空格:

[Unit]
Description=Yellow pages .NET service
ExecStart需要绝对路径,因此出现错误:

[Service]
Type=forking
WorkingDirectory=/home
ExecStart=/usr/bin/dotnet /home/yp_app/YellowPages.dll
您的dotnet可执行文件可能位于其他位置,但您可以通过执行以下操作找到其绝对路径:

$ which dotnet

返回的任何内容都将是要使用的绝对路径。

守护进程有几个问题:

[Unit]
Description = Yellow pages .NET service
删除等号周围的空格:

[Unit]
Description=Yellow pages .NET service
ExecStart需要绝对路径,因此出现错误:

[Service]
Type=forking
WorkingDirectory=/home
ExecStart=/usr/bin/dotnet /home/yp_app/YellowPages.dll
您的dotnet可执行文件可能位于其他位置,但您可以通过执行以下操作找到其绝对路径:

$ which dotnet

返回的任何内容都将是要使用的绝对路径。

@Chris WilliamsPlease发布此命令的结果:whichdotnet@ChrisWilliamsPlease发布此命令的结果:哪个点进行了更改,不再出现该错误。但是当我尝试通过以下方式启用服务:systemctl enable YellowPages.service:未能启用单元:无效参数当我检查系统日志时,我看到:CRON[8868]:root CMD命令-v debian-sa1>/dev/null&&debian-sa11@sumanthshetty:显示您试图启动服务的命令。它应该是:systemctl start yellowpage。带有cron错误的第二条注释是不相关的。如果不起作用,请在输出后立即使用journalctl-xe并发布。@I'L'I我使用了systemctl start Yellowpages.service无法启动Yellowpages.service:Unit Yellowpages.service未正确加载:Exec格式错误。有关详细信息,请参阅系统日志和“systemctl status YellowPages.service”。当我检查syslog/lib/systemd/system/YellowPages.service:7:工作目录路径“home/yp_app”不是绝对的。如何找到应用程序文件夹的绝对路径。我起诉了PWDIt看起来你错过了家的开头/ypp。。。。当您在工作目录try:pwd上时,它应该返回完整的绝对路径。更改是否不再获得该错误。但是当我尝试通过以下方式启用服务:systemctl enable YellowPages.service:未能启用单元:无效参数当我检查系统日志时,我看到:CRON[8868]:root CMD命令-v debian-sa1>/dev/null&&debian-sa11@sumanthshetty:显示您试图启动服务的命令。它应该是:systemctl start yellowpage。带有cron错误的第二条注释是不相关的。如果不起作用,请在输出后立即使用journalctl-xe并发布。@I'L'I我使用了systemctl start Yellowpages.service无法启动Yellowpages.service:Unit Yellowpages.service未正确加载:Exec格式错误。有关详细信息,请参阅系统日志和“systemctl status YellowPages.service”。当我检查syslog/lib/systemd/system/YellowPages.service:7:工作目录路径“home/yp_app”不是绝对的。如何找到应用程序文件夹的绝对路径。我起诉了PWDIt看起来你错过了家的开头/ypp。。。。当您在工作目录try:pwd上时,它应该返回完整的绝对路径。