0

We have created a custom application using .net core 6.0 and the binaries of this application are kept at /usr/bin/IMIC.

It is running as a service on RHEL 8.8. The service file IMIC.service is located at /etc/systemd/system/.

The contents of IMIC.service is as below :

[Unit]
Description=IMIC service application

[Service] Type=notify WorkingDirectory=/usr/bin/IMIC ExecStart=/usr/bin/IMIC/IMIC

[Install] WantedBy=multi-user.target

Currently, if we want to launch this service, it is mandatory to use sudo as below

sudo systemctl start IMIC

But requirement is we need to launch this service without using sudo as shown below:

systemctl start IMIC

When we launch above command it is giving some errors.

Could you help us how to launch custom service without using sudo? Your help is really appreciated:)

kiran
  • 1
  • 2
    One way is to make config sudoers, so the user does not have to enter the password when running sudo: https://unix.stackexchange.com/questions/192706/how-could-we-allow-non-root-users-to-control-a-systemd-service Another way is to create a service for a user: https://unix.stackexchange.com/questions/606452/allowing-user-to-run-systemctl-systemd-services-without-password – nobody Feb 26 '24 at 11:35
  • my requirement is to run the service without using sudo in the command. by using 'systemctl start IMIC' command I should be able to run the service. – kiran Feb 28 '24 at 11:20
  • Then you should explore option two (https://unix.stackexchange.com/questions/606452/allowing-user-to-run-systemctl-systemd-services-without-password). – nobody Feb 28 '24 at 11:52
  • This worked for me thank you. – kiran Mar 01 '24 at 05:06
  • Now I'm able to run the service without using sudo by using the command 'systemctl --user start IMIC' but the application is stopping indeterminately. sometimes service will run for 1-2 hours and sometimes 5-6 hours. maybe this is due user session timeout. now I want the service to run continuously even when the user session is terminated. can you please help me to achieve this? your help will be appreciated. – kiran Mar 11 '24 at 08:51
  • The service should not be affected by user session. I would first inspect log of the service to see, why is it being stopped. Try journalctl -u IMIC and see what it is reporting. – nobody Mar 11 '24 at 09:26
  • No errors in the journal logs. Application is stopping when user is logged out. Mar 11 17:19:14 NMS97_A2 systemd[1397686]: Stopping IMIC service application... Mar 11 17:19:14 NMS97_A2 IMIC[1397853]: Microsoft.Hosting.Lifetime[0] Application is shutting down... – kiran Mar 12 '24 at 05:13

0 Answers0