0

I'm trying to install .NET Core(3.1) app in Centos8 using steps given in MS enter .

Service File as per Microsoft document /etc/systemd/system/kestrel-dotnetapp.service

[Unit]
Description= .NET Web API App for centos

[Service]
WorkingDirectory=/var/Application/netcoreapp31
ExecStart=/usr/local/dotnet /var/Application/netcoreapp31/helloapp.dll
Restart=always # Restart service after 10 seconds if the dotnet service crashes:
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=dotnetapp
User=user
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false

[Install]
WantedBy=multi-user.target

When i do > sudo systemctl restart kestrel-dotnetapp.service am getting error.

Jun 04 22:51:28 hostname systemd[1827]: kestrel-dotnetapp.service: Failed to execute command: Permission denied
Jun 04 22:51:28 hostname systemd[1827]: kestrel-dotnetapp.service: Failed at step EXEC spawning /usr/local/dotnet: Permission denied
-- Subject: Process /usr/local/dotnet could not be executed
-- Defined-By: systemd

Find below ls -la :

[user@hostname dotnet]$ ls -la
total 108
drwxr-xr-x.  4 root root    94 Apr 22 09:34 .
drwxr-xr-x. 14 root root   154 Jun  4 21:11 ..
-rwxr-xr-x.  1 root root 73048 Apr 22 09:32 dotnet
drwxr-xr-x.  3 root root    17 Apr 22 09:34 host
-rw-r--r--.  1 root root  1116 Apr 22 09:29 LICENSE.txt
drwxr-xr-x.  4 root root    67 Apr 22 09:34 shared
-rw-r--r--.  1 root root 31330 Apr 22 09:29 ThirdPartyNotices.txt

My application deliverables folder

[user@hostname Application]$ ls -la
total 8
drwxr-xr-x.  3 root root     26 Jun  4 20:53 .
drwxr-xr-x. 22 root root   4096 Jun  4 20:53 ..
drwxr-xr-x.  2  777 user 4096 Jun  4 20:45 netcoreapp31
4
  • You ran ls -la but you don’t tell us where it is. Your unit says the executable is /usr/local/dotnet, but the ls output has a dotnet executable in it, and the directory name is “dotnet”. Are you sure you don’t mean to use /usr/local/dotnet/dotnet as the executable in the ExecStart?
    – jsbillings
    Jun 5, 2020 at 1:40
  • Hi @jsbillings dotnet is available in /usr/local/dotnet folder !! i have ran ls -la in /usr/local/dotnet . i tried putting /usr/local/dotnet/dotnet as executable Start even-though it wasn't in MS doc still nothing helped me
    – A.K
    Jun 5, 2020 at 6:49
  • When you changed it to /usr/local/dotnet/dotnet, did the errors change?
    – jsbillings
    Jun 5, 2020 at 11:55
  • @jsbillings it worked !!! after changing ExecStart to /usr/local/dotnet/dotnet and gave access with chmod 755, service started successfully i don't know why microsoft mentioned till ~/dotnet is enough though Thanks !!
    – A.K
    Jun 6, 2020 at 15:54

1 Answer 1

0

Please find below solution for redhat os usr/bin/dotnet permission denied.

  1. ExecStart=/usr/bin/dotnet/dotnet
  2. Gave permission to service file like chmod 755 your filename.service
  3. After gave permission execute below command
    sudo systemctl enable Your filename.service
    sudo systemctl start  Your filename.service  
    sudo systemctl status Your filename.service          
    

Example for yourfilename: abc.service

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .