Question

nginx service stopped after exiting the server throws (code=exited, status=147)

Posted May 5, 2021 174 views
DigitalOcean

Services exited with the below code.

Service file:

[Unit]
Description=Sample services

[Service]
WorkingDirectory=/var/www/services
ExecStart=/usr/bin/dotnet /var/www/services/Sample.dll
Restart=always
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=services
User=www-data
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false

[Install]
WantedBy=multi-user.target

Running sudo systemctl status services.service shows below issue with code exited and status as 147:

 services.service - Sample services
     Loaded: loaded (/etc/systemd/system/services.service; enabled; vendor preset: enabled)
     Active: activating (auto-restart) (Result: exit-code) since Wed 2021-05-05 12:00:59 UTC; 172ms ago
    Process: 288358 ExecStart=/usr/bin/dotnet /var/www/services/Sample.dll (code=exited, status=147)
   Main PID: 288358 (code=exited, status=147)

May 05 12:00:59 ubuntu-s-1vcpu-1gb-nyc3-01 systemd[1]: services.service: Main process exited, code=exited, status=147/n/a
May 05 12:00:59 ubuntu-s-1vcpu-1gb-nyc3-01 systemd[1]: services.service: Failed with result 'exit-code'.
edited by bobbyiliev

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
2 answers

Hi there,

Does the service run as expected if you run it with /usr/bin/dotnet /var/www/services/Sample.dll directly?

I could also suggest running the following command and checking for some more errors there:

journalctl -xe

Feel free to share the errors here.

Regards,
Bobby

  • Hi Bobby

    Thanks for the update. This is the error that occurs.

    pam_unix(sudo:auth): Couldn’t open /etc/securetty: No such file or directory

    Can you please help with this?

    • Hi there,

      You could run the following command to copy a default securetty file to that location:

      sudo cp /usr/share/doc/util-linux/examples/securetty /etc/securetty
      

      Let me know how it goes after that.
      Regards,
      Bobby

      • Hi Bobby,

        Thanks, but still I face this issue.

        pamunix(sudo:auth): Couldn’t open /etc/securetty: No such file or directory
        ubuntu-s-1vcpu-1gb-nyc3-01 sudo[495678]: pam
        unix(sudo:auth): Couldn’t open /etc/securetty: No such file or directory
        ubuntu-s-1vcpu-1gb-nyc3-01 sudo[495678]: pamunix(sudo:auth): authentication failure; logname=username uid=1000 euid=0 tty=/dev/pts/0 ruse>
        ubuntu-s-1vcpu-1gb-nyc3-01 sudo[495678]: pam
        unix(sudo:auth): Couldn’t open /etc/securetty: No such file or directory
        ubuntu-s-1vcpu-1gb-nyc3-01 sudo[495678]: pam_unix(sudo:auth): Couldn’t open /etc/securetty: No such file or directory

Hi @thirukumaranmurugan,

In cases such as this, I always suggest checking out you error_logs. If that doesn’t help you can always try to restart the service

systemctl restart ServiceName

and immediately after that follow the journal just as @bobbyiliev suggested:

journalctl -xe

This is just because (code=exited, status=147) is a very generic error and you’ll see a more descriptive error in either the error log or in the journal. Once you know the exact error you can act upon them