question

Prabs-7622 avatar image
0 Votes"
Prabs-7622 asked Prabs-7622 answered

How to create service application in Linux using C#.Net Core 3.1?

Hi Team,

I have a C# .NET Core 3.1 console application which is running on terminal window in RedHat Linux.
It is a long running application. it runs 24/7.
I need to change from console to service application (like windows service in windows OS) which should running on background in Linux.

Could you please help me on this?

Regards,
Prabhakaran

dotnet-csharpdotnet-runtimedotnet-runtime-frameworkdotnet-runtime-core
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

lextm avatar image
0 Votes"
lextm answered

You need to utilize systemd and Microsoft has a very detailed sample to guide you,

https://devblogs.microsoft.com/dotnet/net-core-and-systemd/

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Bruce-SqlWork avatar image
0 Votes"
Bruce-SqlWork answered

You can any console app with cron, or create a daemon process.

In Unix/Linux you create a daemon process, by disconnecting from the console. You do this by forking and redirecting stdout to a log file.

Fortunately ms has wrapped this up for with their service worker project type and UseSystemd(). See

https://devblogs.microsoft.com/dotnet/net-core-and-systemd/





5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Prabs-7622 avatar image
0 Votes"
Prabs-7622 answered

Thanks team. I will test it out and come back if I face any issues.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Prabs-7622 avatar image
0 Votes"
Prabs-7622 answered

Hello Team,

I have one new requirement.
When i run the sudo systemctl start testapp.service command, application has to wait for config file path provided by user.

I tried the following code but it is not showing in Linux terminal window

Console.WriteLine("Enter config file path :");
string configFilepath = Console.ReadLine();

Could you please help me on this?

Regards,
Prabs

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.