How to close .net core console application on linux machine?

Prabs 1 Reputation point
2021-04-26T05:52:33.053+00:00

Hi,
How to close .Net core console application in linux machine?
Becasue .Net core console application is running on terminal window on linux.
If user want to close application,how to allow to user to close it? my application is long running process...
If i close the terminal window,console also will close?

Developer technologies .NET .NET Runtime
Developer technologies .NET .NET CLI
Developer technologies C#
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. cheong00 3,486 Reputation points Volunteer Moderator
    2021-04-26T10:54:33.043+00:00

    Adding " &" when running command in *nix will put it into background.

    You can then just ignore it, or use "wait" command to wait until the background process you just run ends.

    Although I'll probably wrap it as systemd service.

    In both way, you can let users kill them by adding the followings to your /etc/sudoers file.

    <username> ALL = /usr/bin/pkill <yourprocessname>
    <username> ALL = /usr/bin/pkill stop <yourservicename>, /usr/bin/pkill start <yourservicename>

    where <username>,<yourprocessname> and <yourservicename> are all placeholders which you should change accordingly.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.