Create .NET service on linux

Linux

Following an article that described how to create a windows service from a .NET core application (or actually any other binary): https://alexrait.blogspot.com/2021/07/how-to-create-service-in-windows.html, we would like to do the same on a Linux machine

On Linux we use systemctl and the .service file that describes the service

This article: https://swimburger.net/blog/dotnet/how-to-run-a-dotnet-core-console-app-as-a-service-using-systemd-on-linux descibes well how to do the setup.

For .NET, an additional option is useful: WorkingFolder=/some/path, since some of the path references in the app might be relative.

Some useful commands:

  1. systemctl enable ServiceName
  2. systemctl daemon-reload
  3. systemctl start ServiceName
  4. systemctl status ServiceName
  5. journalctl -u ServiceName -f

Post a Comment

Previous Post Next Post