Score:0

redhat linux 8 systemd service error 203

az flag
  1. Deployed a sample dot net core web api to EC2 instance in /var/www/hello-app folder using the user “ec2-user” in FileZilla

  2. The folder contains the required dlls and other dotnet files

  3. Installed apache web server on the ec2 instance and started the web server

  4. Ran the dotnet service from command line to make sure it works using command below

cd /usr/lib64/dotnet
dotnet /var/www/helloapp/WebApi4.dll
  1. I Created the systemd service for the Dot net web api as follows
sudo  vim /etc/systemd/system/kestrel-helloapp.service

[Unit]
Description=Example .NET Web API App 

[Service]
WorkingDirectory=/var/www/helloapp
ExecStart=/usr/lib64/dotnet /var/www/helloapp/WebApi4.dll
Restart=always
# Restart service after 10 seconds if the dotnet service crashes:
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=dotnet-example
User=apache
Environment=ASPNETCORE_ENVIRONMENT=Production 
Environment=ASPNETCORE_URLS=http://localhost:5000

[Install]
WantedBy=multi-user.target
When I run following commands
sudo systemctl enable kestrel-helloapp.service
sudo systemctl start kestrel-helloapp.service
sudo systemctl status kestrel-helloapp.service
I get following error (203/EXEC) for the third command 
[ec2-user@ip-172-31-81-1 dotnet]$ sudo systemctl status kestrel-helloapp.service
● kestrel-helloapp.service - Example .NET Web API App running on CentOS 7
   Loaded: loaded (/etc/systemd/system/kestrel-helloapp.service; enabled; vendor preset: disabled)
   Active: activating (auto-restart) (Result: exit-code) since Tue 2022-01-11 15:40:30 UTC; 6s ago
  Process: 71626 ExecStart=/usr/lib64/dotnet /var/www/helloapp/WebApi4.dll (code=exited, status=203/EXEC)
 Main PID: 71626 (code=exited, status=203/EXEC)

Jan 11 15:40:30 ip-172-31-81-1.ec2.internal systemd[1]: kestrel-helloapp.service: Main process exited, code=exited, status=203/EXEC
Jan 11 15:40:30 ip-172-31-81-1.ec2.internal systemd[1]: kestrel-helloapp.service: Failed with result 'exit-code'.
  1. Opened port 5000 using
sudo firewall-cmd --add-port=5000/tcp --permanent
  1. Made apache owner of /var/www folder
sudo chown -R apache:apache /var/www
sudo chmod -R 550 /var/www

I looked up the error and possible reasons related to the error, found following. Check everything I can think of, still the same

The error message (code=exited, status=203/EXEC) is often seen when the script itself or its interpreter cannot be executed.

It could have these reasons:
    wrong path to script (e.g. /home/py/ReadPressure2AndPostToMqtt.py)
    script not executable
    no shebang (first line)
    wrong path in shebang (e.g. /bin/python3)
    internal files in your script might be missing access permissions.
    SELinux may be preventing execution of the ExecStart parameter; check /var/log/audit/audit.log for messages of the form: type=AVC msg=audit([...]): avc:  denied  { execute } or in the output of ausearch -ts recent -m avc -i.
    You have the wrong WorkingDirectory parameter
jp flag
What happens if you disable SELinux using 'sudo setenforce 0'?
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.